generic: Support Altima AMI101L PHY
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 826-v6.6-01-led-trig-netdev-Fix-requesting-offload-device.patch
1 From 7df1f14c04cbb1950e79c19793420f87227c3e80 Mon Sep 17 00:00:00 2001
2 From: Andrew Lunn <andrew@lunn.ch>
3 Date: Tue, 8 Aug 2023 23:04:33 +0200
4 Subject: [PATCH 1/4] led: trig: netdev: Fix requesting offload device
5
6 When the netdev trigger is activates, it tries to determine what
7 device the LED blinks for, and what the current blink mode is.
8
9 The documentation for hw_control_get() says:
10
11 * Return 0 on success, a negative error number on failing parsing the
12 * initial mode. Error from this function is NOT FATAL as the device
13 * may be in a not supported initial state by the attached LED trigger.
14 */
15
16 For the Marvell PHY and the Armada 370-rd board, the initial LED blink
17 mode is not supported by the trigger, so it returns an error. This
18 resulted in not getting the device the LED is blinking for. As a
19 result, the device is unknown and offloaded is never performed.
20
21 Change to condition to always get the device if offloading is
22 supported, and reduce the scope of testing for an error from
23 hw_control_get() to skip setting trigger internal state if there is an
24 error.
25
26 Reviewed-by: Simon Horman <simon.horman@corigine.com>
27 Signed-off-by: Andrew Lunn <andrew@lunn.ch>
28 Tested-by: Daniel Golle <daniel@makrotopia.org>
29 Link: https://lore.kernel.org/r/20230808210436.838995-2-andrew@lunn.ch
30 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
31 ---
32 drivers/leds/trigger/ledtrig-netdev.c | 8 +++++---
33 1 file changed, 5 insertions(+), 3 deletions(-)
34
35 --- a/drivers/leds/trigger/ledtrig-netdev.c
36 +++ b/drivers/leds/trigger/ledtrig-netdev.c
37 @@ -564,15 +564,17 @@ static int netdev_trig_activate(struct l
38 /* Check if hw control is active by default on the LED.
39 * Init already enabled mode in hw control.
40 */
41 - if (supports_hw_control(led_cdev) &&
42 - !led_cdev->hw_control_get(led_cdev, &mode)) {
43 + if (supports_hw_control(led_cdev)) {
44 dev = led_cdev->hw_control_get_device(led_cdev);
45 if (dev) {
46 const char *name = dev_name(dev);
47
48 set_device_name(trigger_data, name, strlen(name));
49 trigger_data->hw_control = true;
50 - trigger_data->mode = mode;
51 +
52 + rc = led_cdev->hw_control_get(led_cdev, &mode);
53 + if (!rc)
54 + trigger_data->mode = mode;
55 }
56 }
57