Skip to content

Commit

Permalink
leds: add API to get attached device for LED hw control
Browse files Browse the repository at this point in the history
Some specific LED triggers blink the LED based on events from a device
or subsystem.
For example, an LED could be blinked to indicate a network device is
receiving packets, or a disk is reading blocks. To correctly enable and
request the hw control of the LED, the trigger has to check if the
network interface or block device configured via a /sys/class/led file
match the one the LED driver provide for hw control for.

Provide an API call to get the device which the LED blinks for.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Andrew Lunn authored and David S. Miller committed May 31, 2023
1 parent ed554d3 commit 052c38e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/linux/leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ struct led_classdev {
*/
int (*hw_control_get)(struct led_classdev *led_cdev,
unsigned long *flags);
/*
* Get the device this LED blinks in response to.
* e.g. for a PHY LED, it is the network device. If the LED is
* not yet associated to a device, return NULL.
*/
struct device *(*hw_control_get_device)(struct led_classdev *led_cdev);
#endif

#ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED
Expand Down

0 comments on commit 052c38e

Please sign in to comment.