09759bc623e9c0cd88cfc648e46205a5ae6844b6
[openwrt/staging/xback.git] /
1 From 6352f25f9fadba59d5df2ba7139495759ccc81d5 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Mon, 29 May 2023 18:32:36 +0200
4 Subject: [PATCH 06/13] leds: trigger: netdev: add basic check for hw control
5 support
6
7 Add basic check for hw control support. Check if the required API are
8 defined and check if the defined trigger supported in hw control for the
9 LED driver match netdev.
10
11 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
12 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/leds/trigger/ledtrig-netdev.c | 14 ++++++++++++++
16 1 file changed, 14 insertions(+)
17
18 --- a/drivers/leds/trigger/ledtrig-netdev.c
19 +++ b/drivers/leds/trigger/ledtrig-netdev.c
20 @@ -92,8 +92,22 @@ static void set_baseline_state(struct le
21 }
22 }
23
24 +static bool supports_hw_control(struct led_classdev *led_cdev)
25 +{
26 + if (!led_cdev->hw_control_get || !led_cdev->hw_control_set ||
27 + !led_cdev->hw_control_is_supported)
28 + return false;
29 +
30 + return !strcmp(led_cdev->hw_control_trigger, led_cdev->trigger->name);
31 +}
32 +
33 static bool can_hw_control(struct led_netdev_data *trigger_data)
34 {
35 + struct led_classdev *led_cdev = trigger_data->led_cdev;
36 +
37 + if (!supports_hw_control(led_cdev))
38 + return false;
39 +
40 return false;
41 }
42