mtd: fix build with GCC 14
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 818-v6.5-01-leds-add-APIs-for-LEDs-hw-control.patch
1 From ed554d3f945179c5b159bddfad7be34b403fe11a Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Mon, 29 May 2023 18:32:31 +0200
4 Subject: [PATCH 01/13] leds: add APIs for LEDs hw control
5
6 Add an option to permit LED driver to declare support for a specific
7 trigger to use hw control and setup the LED to blink based on specific
8 provided modes.
9
10 Add APIs for LEDs hw control. These functions will be used to activate
11 hardware control where a LED will use the provided flags, from an
12 unique defined supported trigger, to setup the LED to be driven by
13 hardware.
14
15 Add hw_control_is_supported() to ask the LED driver if the requested
16 mode by the trigger are supported and the LED can be setup to follow
17 the requested modes.
18
19 Deactivate hardware blink control by setting brightness to LED_OFF via
20 the brightness_set() callback.
21
22 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
23 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
24 Signed-off-by: David S. Miller <davem@davemloft.net>
25 ---
26 include/linux/leds.h | 37 +++++++++++++++++++++++++++++++++++++
27 1 file changed, 37 insertions(+)
28
29 --- a/include/linux/leds.h
30 +++ b/include/linux/leds.h
31 @@ -164,6 +164,43 @@ struct led_classdev {
32
33 /* LEDs that have private triggers have this set */
34 struct led_hw_trigger_type *trigger_type;
35 +
36 + /* Unique trigger name supported by LED set in hw control mode */
37 + const char *hw_control_trigger;
38 + /*
39 + * Check if the LED driver supports the requested mode provided by the
40 + * defined supported trigger to setup the LED to hw control mode.
41 + *
42 + * Return 0 on success. Return -EOPNOTSUPP when the passed flags are not
43 + * supported and software fallback needs to be used.
44 + * Return a negative error number on any other case for check fail due
45 + * to various reason like device not ready or timeouts.
46 + */
47 + int (*hw_control_is_supported)(struct led_classdev *led_cdev,
48 + unsigned long flags);
49 + /*
50 + * Activate hardware control, LED driver will use the provided flags
51 + * from the supported trigger and setup the LED to be driven by hardware
52 + * following the requested mode from the trigger flags.
53 + * Deactivate hardware blink control by setting brightness to LED_OFF via
54 + * the brightness_set() callback.
55 + *
56 + * Return 0 on success, a negative error number on flags apply fail.
57 + */
58 + int (*hw_control_set)(struct led_classdev *led_cdev,
59 + unsigned long flags);
60 + /*
61 + * Get from the LED driver the current mode that the LED is set in hw
62 + * control mode and put them in flags.
63 + * Trigger can use this to get the initial state of a LED already set in
64 + * hardware blink control.
65 + *
66 + * Return 0 on success, a negative error number on failing parsing the
67 + * initial mode. Error from this function is NOT FATAL as the device
68 + * may be in a not supported initial state by the attached LED trigger.
69 + */
70 + int (*hw_control_get)(struct led_classdev *led_cdev,
71 + unsigned long *flags);
72 #endif
73
74 #ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED