0a4b309f41
Backport initial LEDs hw control support. Currently this is limited to only rx/tx and link events for the netdev trigger but the API got accepted and the additional modes are working on and will be backported later. Refresh every patch and add the additional config flag for QCA8K new LEDs support. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
70 lines
2.0 KiB
Diff
70 lines
2.0 KiB
Diff
From 28a6a2ef18ad840a390d519840c303b03040961c Mon Sep 17 00:00:00 2001
|
|
From: Andrew Lunn <andrew@lunn.ch>
|
|
Date: Mon, 29 May 2023 18:32:34 +0200
|
|
Subject: [PATCH 04/13] leds: trigger: netdev: refactor code setting device
|
|
name
|
|
|
|
Move the code into a helper, ready for it to be called at
|
|
other times. No intended behaviour change.
|
|
|
|
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
|
|
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
---
|
|
drivers/leds/trigger/ledtrig-netdev.c | 29 ++++++++++++++++++---------
|
|
1 file changed, 20 insertions(+), 9 deletions(-)
|
|
|
|
--- a/drivers/leds/trigger/ledtrig-netdev.c
|
|
+++ b/drivers/leds/trigger/ledtrig-netdev.c
|
|
@@ -104,15 +104,9 @@ static ssize_t device_name_show(struct d
|
|
return len;
|
|
}
|
|
|
|
-static ssize_t device_name_store(struct device *dev,
|
|
- struct device_attribute *attr, const char *buf,
|
|
- size_t size)
|
|
+static int set_device_name(struct led_netdev_data *trigger_data,
|
|
+ const char *name, size_t size)
|
|
{
|
|
- struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
|
|
-
|
|
- if (size >= IFNAMSIZ)
|
|
- return -EINVAL;
|
|
-
|
|
cancel_delayed_work_sync(&trigger_data->work);
|
|
|
|
mutex_lock(&trigger_data->lock);
|
|
@@ -122,7 +116,7 @@ static ssize_t device_name_store(struct
|
|
trigger_data->net_dev = NULL;
|
|
}
|
|
|
|
- memcpy(trigger_data->device_name, buf, size);
|
|
+ memcpy(trigger_data->device_name, name, size);
|
|
trigger_data->device_name[size] = 0;
|
|
if (size > 0 && trigger_data->device_name[size - 1] == '\n')
|
|
trigger_data->device_name[size - 1] = 0;
|
|
@@ -140,6 +134,23 @@ static ssize_t device_name_store(struct
|
|
set_baseline_state(trigger_data);
|
|
mutex_unlock(&trigger_data->lock);
|
|
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static ssize_t device_name_store(struct device *dev,
|
|
+ struct device_attribute *attr, const char *buf,
|
|
+ size_t size)
|
|
+{
|
|
+ struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
|
|
+ int ret;
|
|
+
|
|
+ if (size >= IFNAMSIZ)
|
|
+ return -EINVAL;
|
|
+
|
|
+ ret = set_device_name(trigger_data, buf, size);
|
|
+
|
|
+ if (ret < 0)
|
|
+ return ret;
|
|
return size;
|
|
}
|
|
|