804-v6.5-05-leds-trigger-netdev-introduce-check-for-possible-hw-.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 4fd1b6d47a7a38e81fdc6f8be2ccd4216b3f93db Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Mon, 29 May 2023 18:32:35 +0200
  4. Subject: [PATCH 05/13] leds: trigger: netdev: introduce check for possible hw
  5. control
  6. Introduce function to check if the requested mode can use hw control in
  7. preparation for hw control support. Currently everything is handled in
  8. software so can_hw_control will always return false.
  9. Add knob with the new value hw_control in trigger_data struct to
  10. set hw control possible. Useful for future implementation to implement
  11. in set_baseline_state() the required function to set the requested mode
  12. using LEDs hw control ops and in other function to reject set if hw
  13. control is currently active.
  14. Signed-off-by: Christian Marangi <[email protected]>
  15. Reviewed-by: Andrew Lunn <[email protected]>
  16. Signed-off-by: David S. Miller <[email protected]>
  17. ---
  18. drivers/leds/trigger/ledtrig-netdev.c | 8 ++++++++
  19. 1 file changed, 8 insertions(+)
  20. --- a/drivers/leds/trigger/ledtrig-netdev.c
  21. +++ b/drivers/leds/trigger/ledtrig-netdev.c
  22. @@ -51,6 +51,7 @@ struct led_netdev_data {
  23. unsigned long mode;
  24. bool carrier_link_up;
  25. + bool hw_control;
  26. };
  27. enum led_trigger_netdev_modes {
  28. @@ -91,6 +92,11 @@ static void set_baseline_state(struct le
  29. }
  30. }
  31. +static bool can_hw_control(struct led_netdev_data *trigger_data)
  32. +{
  33. + return false;
  34. +}
  35. +
  36. static ssize_t device_name_show(struct device *dev,
  37. struct device_attribute *attr, char *buf)
  38. {
  39. @@ -204,6 +210,8 @@ static ssize_t netdev_led_attr_store(str
  40. else
  41. clear_bit(bit, &trigger_data->mode);
  42. + trigger_data->hw_control = can_hw_control(trigger_data);
  43. +
  44. set_baseline_state(trigger_data);
  45. return size;