[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220503151633.18760-9-ansuelsmth@gmail.com>
Date: Tue, 3 May 2022 17:16:30 +0200
From: Ansuel Smith <ansuelsmth@...il.com>
To: Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Jonathan Corbet <corbet@....net>, Pavel Machek <pavel@....cz>,
Ansuel Smith <ansuelsmth@...il.com>,
John Crispin <john@...ozen.org>, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, linux-leds@...r.kernel.org
Subject: [RFC PATCH v6 08/11] leds: trigger: netdev: add available mode sysfs attr
Add avaiable_mode sysfs attr to show and give some details about the
supported modes and how they can be handled by the trigger.
This is in preparation for hardware only modes that doesn't support
software fallback.
Signed-off-by: Ansuel Smith <ansuelsmth@...il.com>
---
drivers/leds/trigger/ledtrig-netdev.c | 32 +++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index a471e0cde836..d88b0c6a910e 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -33,6 +33,8 @@
* (has carrier) or not
* tx - LED blinks on transmitted data
* rx - LED blinks on receive data
+ * available_mode - Display available mode and how they can be handled
+ * by the LED
*
*/
@@ -370,12 +372,42 @@ static ssize_t interval_store(struct device *dev,
static DEVICE_ATTR_RW(interval);
+static ssize_t available_mode_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
+ struct netdev_led_attr_detail *detail;
+ int i, len = 0;
+
+ for (i = 0; i < ARRAY_SIZE(attr_details); i++) {
+ detail = &attr_details[i];
+
+ if (led_trigger_blink_mode_is_supported(trigger_data->led_cdev, detail->bit)) {
+ if (!trigger_data->net_dev) {
+ if (detail->hardware_only)
+ len += sprintf(buf+len, "%s [hardware]\n",
+ detail->name);
+ else
+ len += sprintf(buf+len, "%s [software-hardware]\n",
+ detail->name);
+ }
+ } else {
+ len += sprintf(buf+len, "%s [software]\n", detail->name);
+ }
+ }
+
+ return len;
+}
+
+static DEVICE_ATTR_RO(available_mode);
+
static struct attribute *netdev_trig_attrs[] = {
&dev_attr_device_name.attr,
&dev_attr_link.attr,
&dev_attr_rx.attr,
&dev_attr_tx.attr,
&dev_attr_interval.attr,
+ &dev_attr_available_mode.attr,
NULL
};
ATTRIBUTE_GROUPS(netdev_trig);
--
2.34.1
Powered by blists - more mailing lists