diff mbox series

[06/11] leds: trigger: netdev: add knob to set hw control possible

Message ID 20230427001541.18704-7-ansuelsmth@gmail.com
State New
Headers show
Series leds: introduce new LED hw control APIs | expand

Commit Message

Christian Marangi April 27, 2023, 12:15 a.m. UTC
Add knob with the new value hw_control in trigger_data struct to
set hw control possible. Useful for future implementation to implement
in set_baseline_state() the required function to set the requested mode
using LEDs hw control ops and in other function to reject set if hw
control is currently active.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/leds/trigger/ledtrig-netdev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index 81e0b0083f2f..28c4465a2584 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -51,6 +51,7 @@  struct led_netdev_data {
 
 	unsigned long mode;
 	bool carrier_link_up;
+	bool hw_control;
 };
 
 enum led_trigger_netdev_modes {
@@ -92,7 +93,7 @@  static void set_baseline_state(struct led_netdev_data *trigger_data)
 }
 
 static int validate_requested_mode(struct led_netdev_data *trigger_data,
-				   unsigned long mode)
+				   unsigned long mode, bool *can_use_hw_control)
 {
 	return 0;
 }
@@ -175,6 +176,7 @@  static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
 {
 	struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
 	unsigned long state, new_mode = trigger_data->mode;
+	bool can_use_hw_control = false;
 	int ret;
 	int bit;
 
@@ -197,13 +199,15 @@  static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
 	else
 		clear_bit(bit, &new_mode);
 
-	ret = validate_requested_mode(trigger_data, new_mode);
+	ret = validate_requested_mode(trigger_data, new_mode,
+				      &can_use_hw_control);
 	if (ret)
 		return ret;
 
 	cancel_delayed_work_sync(&trigger_data->work);
 
 	trigger_data->mode = new_mode;
+	trigger_data->hw_control = can_use_hw_control;
 
 	set_baseline_state(trigger_data);