From: Christian Marangi Date: Mon, 19 Jun 2023 20:47:00 +0000 (+0200) Subject: leds: trigger: netdev: expose hw_control status via sysfs X-Git-Tag: v6.5-rc1~163^2~48^2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=b655892ffd6d89b0c7407e099c40dbde82ee3f03;p=linux-2.6-block.git leds: trigger: netdev: expose hw_control status via sysfs Expose hw_control status via sysfs for the netdev trigger to give userspace better understanding of the current state of the trigger and the LED. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn Reviewed-by: Kalesh AP Acked-by: Lee Jones Signed-off-by: Jakub Kicinski --- diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c index 2c1c9e95860e..32b66703068a 100644 --- a/drivers/leds/trigger/ledtrig-netdev.c +++ b/drivers/leds/trigger/ledtrig-netdev.c @@ -406,6 +406,16 @@ static ssize_t interval_store(struct device *dev, static DEVICE_ATTR_RW(interval); +static ssize_t hw_control_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev); + + return sprintf(buf, "%d\n", trigger_data->hw_control); +} + +static DEVICE_ATTR_RO(hw_control); + static struct attribute *netdev_trig_attrs[] = { &dev_attr_device_name.attr, &dev_attr_link.attr, @@ -417,6 +427,7 @@ static struct attribute *netdev_trig_attrs[] = { &dev_attr_rx.attr, &dev_attr_tx.attr, &dev_attr_interval.attr, + &dev_attr_hw_control.attr, NULL }; ATTRIBUTE_GROUPS(netdev_trig);