aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/backport-5.15/818-v6.5-09-leds-trigger-netdev-validate-configured-netdev.patch
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2023-06-04 04:26:59 +0200
committerDaniel Golle <daniel@makrotopia.org>2023-09-04 23:00:34 +0100
commitcf08db988baca64b878f1887d13e2fb79a708d8c (patch)
treeb0e70dfa0d51212b0ddc011383431d97138a5fe4 /target/linux/generic/backport-5.15/818-v6.5-09-leds-trigger-netdev-validate-configured-netdev.patch
parente685162a78c07d373bd7b621a716465970680bae (diff)
downloadupstream-cf08db988baca64b878f1887d13e2fb79a708d8c.tar.gz
upstream-cf08db988baca64b878f1887d13e2fb79a708d8c.tar.bz2
upstream-cf08db988baca64b878f1887d13e2fb79a708d8c.zip
generic: backport initial LEDs hw control support
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> Signed-off-by: Daniel Golle <daniel@makrotopia.org> (cherry picked from commit 0a4b309f41062ef40706162ae53b6428982a0685)
Diffstat (limited to 'target/linux/generic/backport-5.15/818-v6.5-09-leds-trigger-netdev-validate-configured-netdev.patch')
-rw-r--r--target/linux/generic/backport-5.15/818-v6.5-09-leds-trigger-netdev-validate-configured-netdev.patch58
1 files changed, 58 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.15/818-v6.5-09-leds-trigger-netdev-validate-configured-netdev.patch b/target/linux/generic/backport-5.15/818-v6.5-09-leds-trigger-netdev-validate-configured-netdev.patch
new file mode 100644
index 0000000000..c129ffa4f5
--- /dev/null
+++ b/target/linux/generic/backport-5.15/818-v6.5-09-leds-trigger-netdev-validate-configured-netdev.patch
@@ -0,0 +1,58 @@
+From 33ec0b53befff2c0a7f3aa19ff08556d60585d6b Mon Sep 17 00:00:00 2001
+From: Andrew Lunn <andrew@lunn.ch>
+Date: Mon, 29 May 2023 18:32:39 +0200
+Subject: [PATCH 09/13] leds: trigger: netdev: validate configured netdev
+
+The netdev which the LED should blink for is configurable in
+/sys/class/led/foo/device_name. Ensure when offloading that the
+configured netdev is the same as the netdev the LED is associated
+with. If it is not, only perform software blinking.
+
+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 | 24 ++++++++++++++++++++++--
+ 1 file changed, 22 insertions(+), 2 deletions(-)
+
+--- a/drivers/leds/trigger/ledtrig-netdev.c
++++ b/drivers/leds/trigger/ledtrig-netdev.c
+@@ -110,6 +110,24 @@ static bool supports_hw_control(struct l
+ return !strcmp(led_cdev->hw_control_trigger, led_cdev->trigger->name);
+ }
+
++/*
++ * Validate the configured netdev is the same as the one associated with
++ * the LED driver in hw control.
++ */
++static bool validate_net_dev(struct led_classdev *led_cdev,
++ struct net_device *net_dev)
++{
++ struct device *dev = led_cdev->hw_control_get_device(led_cdev);
++ struct net_device *ndev;
++
++ if (!dev)
++ return false;
++
++ ndev = to_net_dev(dev);
++
++ return ndev == net_dev;
++}
++
+ static bool can_hw_control(struct led_netdev_data *trigger_data)
+ {
+ unsigned long default_interval = msecs_to_jiffies(NETDEV_LED_DEFAULT_INTERVAL);
+@@ -131,9 +149,11 @@ static bool can_hw_control(struct led_ne
+ /*
+ * net_dev must be set with hw control, otherwise no
+ * blinking can be happening and there is nothing to
+- * offloaded.
++ * offloaded. Additionally, for hw control to be
++ * valid, the configured netdev must be the same as
++ * netdev associated to the LED.
+ */
+- if (!trigger_data->net_dev)
++ if (!validate_net_dev(led_cdev, trigger_data->net_dev))
+ return false;
+
+ /* Check if the requested mode is supported */