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