67528cafe095a9328e7b1296379c3549deb19b35
[openwrt/staging/neocturne.git] /
1 From b655892ffd6d89b0c7407e099c40dbde82ee3f03 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Mon, 19 Jun 2023 22:47:00 +0200
4 Subject: [PATCH 3/3] leds: trigger: netdev: expose hw_control status via sysfs
5
6 Expose hw_control status via sysfs for the netdev trigger to give
7 userspace better understanding of the current state of the trigger and
8 the LED.
9
10 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
11 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
12 Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
13 Acked-by: Lee Jones <lee@kernel.org>
14 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 ---
16 drivers/leds/trigger/ledtrig-netdev.c | 11 +++++++++++
17 1 file changed, 11 insertions(+)
18
19 --- a/drivers/leds/trigger/ledtrig-netdev.c
20 +++ b/drivers/leds/trigger/ledtrig-netdev.c
21 @@ -406,6 +406,16 @@ static ssize_t interval_store(struct dev
22
23 static DEVICE_ATTR_RW(interval);
24
25 +static ssize_t hw_control_show(struct device *dev,
26 + struct device_attribute *attr, char *buf)
27 +{
28 + struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
29 +
30 + return sprintf(buf, "%d\n", trigger_data->hw_control);
31 +}
32 +
33 +static DEVICE_ATTR_RO(hw_control);
34 +
35 static struct attribute *netdev_trig_attrs[] = {
36 &dev_attr_device_name.attr,
37 &dev_attr_link.attr,
38 @@ -417,6 +427,7 @@ static struct attribute *netdev_trig_att
39 &dev_attr_rx.attr,
40 &dev_attr_tx.attr,
41 &dev_attr_interval.attr,
42 + &dev_attr_hw_control.attr,
43 NULL
44 };
45 ATTRIBUTE_GROUPS(netdev_trig);