netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v0 1/3] led: trig: netdev: Fix requesting offload device
@ 2023-06-18 17:39 Andrew Lunn
  2023-06-18 17:39 ` [PATCH net-next v0 2/3] net: phy: phy_device: Call into the PHY driver to set LED offload Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Andrew Lunn @ 2023-06-18 17:39 UTC (permalink / raw)
  To: netdev; +Cc: ansuelsmth, Russell King, Heiner Kallweit, Andrew Lunn

When the netdev trigger is activates, it tries to determine what
device the LED blinks for, and what the current blink mode is.

The documentation for hw_control_get() says:

	 * Return 0 on success, a negative error number on failing parsing the
	 * initial mode. Error from this function is NOT FATAL as the device
	 * may be in a not supported initial state by the attached LED trigger.
	 */

For the Marvell PHY and the Armada 370-rd board, the initial LED blink
mode is not supported by the trigger, so it returns an error. This
resulted in not getting the device the LED is blinking for. As a
result, the device is unknown and offloaded is never performed.

Change to condition to always get the device if offloading is
supported, and reduce the scope of testing for an error from
hw_control_get() to skip setting trigger internal state if there is an
error.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/leds/trigger/ledtrig-netdev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index 2311dae7f070..df61977f1fa2 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -471,15 +471,17 @@ static int netdev_trig_activate(struct led_classdev *led_cdev)
 	/* Check if hw control is active by default on the LED.
 	 * Init already enabled mode in hw control.
 	 */
-	if (supports_hw_control(led_cdev) &&
-	    !led_cdev->hw_control_get(led_cdev, &mode)) {
+	if (supports_hw_control(led_cdev)) {
 		dev = led_cdev->hw_control_get_device(led_cdev);
 		if (dev) {
 			const char *name = dev_name(dev);
 
 			set_device_name(trigger_data, name, strlen(name));
 			trigger_data->hw_control = true;
-			trigger_data->mode = mode;
+
+			rc = led_cdev->hw_control_get(led_cdev, &mode);
+			if (!rc)
+				trigger_data->mode = mode;
 		}
 	}
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-06-19 21:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-18 17:39 [PATCH net-next v0 1/3] led: trig: netdev: Fix requesting offload device Andrew Lunn
2023-06-18 17:39 ` [PATCH net-next v0 2/3] net: phy: phy_device: Call into the PHY driver to set LED offload Andrew Lunn
2023-06-19 14:18   ` Simon Horman
2023-06-19 18:11     ` Russell King (Oracle)
2023-06-19 20:34       ` Simon Horman
2023-06-19 21:27         ` Andrew Lunn
2023-06-18 17:39 ` [PATCH net-next v0 3/3] net: phy: marvell: Add support for offloading LED blinking Andrew Lunn
2023-06-18 19:15   ` Russell King (Oracle)
2023-06-18 20:28     ` Andrew Lunn
2023-06-18 17:50 ` [PATCH net-next v0 1/3] led: trig: netdev: Fix requesting offload device Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).