generic: backport initial LEDs hw control support
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 804-v6.5-02-leds-add-API-to-get-attached-device-for-LED-hw-contr.patch
1 From 052c38eb17e866c5b4cd43924e7a5e20167b55c0 Mon Sep 17 00:00:00 2001
2 From: Andrew Lunn <andrew@lunn.ch>
3 Date: Mon, 29 May 2023 18:32:32 +0200
4 Subject: [PATCH 02/13] leds: add API to get attached device for LED hw control
5
6 Some specific LED triggers blink the LED based on events from a device
7 or subsystem.
8 For example, an LED could be blinked to indicate a network device is
9 receiving packets, or a disk is reading blocks. To correctly enable and
10 request the hw control of the LED, the trigger has to check if the
11 network interface or block device configured via a /sys/class/led file
12 match the one the LED driver provide for hw control for.
13
14 Provide an API call to get the device which the LED blinks for.
15
16 Signed-off-by: Andrew Lunn <andrew@lunn.ch>
17 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
18 Signed-off-by: David S. Miller <davem@davemloft.net>
19 ---
20 include/linux/leds.h | 6 ++++++
21 1 file changed, 6 insertions(+)
22
23 --- a/include/linux/leds.h
24 +++ b/include/linux/leds.h
25 @@ -201,6 +201,12 @@ struct led_classdev {
26 */
27 int (*hw_control_get)(struct led_classdev *led_cdev,
28 unsigned long *flags);
29 + /*
30 + * Get the device this LED blinks in response to.
31 + * e.g. for a PHY LED, it is the network device. If the LED is
32 + * not yet associated to a device, return NULL.
33 + */
34 + struct device *(*hw_control_get_device)(struct led_classdev *led_cdev);
35 #endif
36
37 #ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED