[PATCH 09/11] leds: trigger: netdev: init mode if hw control already active

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On netdev trigger activation, hw control may be already active by
default. If this is the case, init the already active mode and set the
bool to hw_control bool to true to reflect the already set mode in the
trigger_data.

Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
---
 drivers/leds/trigger/ledtrig-netdev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index 61bc19fd0c7a..27df24e6d559 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -465,6 +465,13 @@ static int netdev_trig_activate(struct led_classdev *led_cdev)
 	atomic_set(&trigger_data->interval, msecs_to_jiffies(50));
 	trigger_data->last_activity = 0;
 
+	/* Check if hw control is active by default on the LED.
+	 * Init already enabled mode in hw control.
+	 */
+	if (led_trigger_can_hw_control(led_cdev) &&
+	    !led_cdev->hw_control_get(led_cdev, &trigger_data->mode))
+		trigger_data->hw_control = true;
+
 	led_set_trigger_data(led_cdev, trigger_data);
 
 	rc = register_netdevice_notifier(&trigger_data->notifier);
-- 
2.39.2




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux