mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 15:02:32 +00:00
43 lines
1.3 KiB
Diff
43 lines
1.3 KiB
Diff
|
From 6352f25f9fadba59d5df2ba7139495759ccc81d5 Mon Sep 17 00:00:00 2001
|
||
|
From: Christian Marangi <ansuelsmth@gmail.com>
|
||
|
Date: Mon, 29 May 2023 18:32:36 +0200
|
||
|
Subject: [PATCH 06/13] leds: trigger: netdev: add basic check for hw control
|
||
|
support
|
||
|
|
||
|
Add basic check for hw control support. Check if the required API are
|
||
|
defined and check if the defined trigger supported in hw control for the
|
||
|
LED driver match netdev.
|
||
|
|
||
|
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
||
|
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||
|
---
|
||
|
drivers/leds/trigger/ledtrig-netdev.c | 14 ++++++++++++++
|
||
|
1 file changed, 14 insertions(+)
|
||
|
|
||
|
--- a/drivers/leds/trigger/ledtrig-netdev.c
|
||
|
+++ b/drivers/leds/trigger/ledtrig-netdev.c
|
||
|
@@ -92,8 +92,22 @@ static void set_baseline_state(struct le
|
||
|
}
|
||
|
}
|
||
|
|
||
|
+static bool supports_hw_control(struct led_classdev *led_cdev)
|
||
|
+{
|
||
|
+ if (!led_cdev->hw_control_get || !led_cdev->hw_control_set ||
|
||
|
+ !led_cdev->hw_control_is_supported)
|
||
|
+ return false;
|
||
|
+
|
||
|
+ return !strcmp(led_cdev->hw_control_trigger, led_cdev->trigger->name);
|
||
|
+}
|
||
|
+
|
||
|
static bool can_hw_control(struct led_netdev_data *trigger_data)
|
||
|
{
|
||
|
+ struct led_classdev *led_cdev = trigger_data->led_cdev;
|
||
|
+
|
||
|
+ if (!supports_hw_control(led_cdev))
|
||
|
+ return false;
|
||
|
+
|
||
|
return false;
|
||
|
}
|
||
|
|