[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231104125840.27914-1-klaus.kudielka@gmail.com>
Date: Sat, 4 Nov 2023 13:58:40 +0100
From: Klaus Kudielka <klaus.kudielka@...il.com>
To: Pavel Machek <pavel@....cz>, Lee Jones <lee@...nel.org>
Cc: Andrew Lunn <andrew@...n.ch>,
Christian Marangi <ansuelsmth@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Samuel Holland <samuel@...lland.org>,
Jisheng Zhang <jszhang@...nel.org>,
Li Zetao <lizetao1@...wei.com>, linux-leds@...r.kernel.org,
linux-kernel@...r.kernel.org,
Klaus Kudielka <klaus.kudielka@...il.com>
Subject: [PATCH] leds: triggers: netdev: add a check, whether device is up
Some net devices do not report NO-CARRIER, if they haven't been brought
up. In that case, the netdev trigger results in a wrong link state being
displayed. Fix this, by adding a check, whether the device is up.
Signed-off-by: Klaus Kudielka <klaus.kudielka@...il.com>
---
drivers/leds/trigger/ledtrig-netdev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index e358e77e4b..bd5e21d0f0 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -195,7 +195,8 @@ static void get_device_state(struct led_netdev_data *trigger_data)
{
struct ethtool_link_ksettings cmd;
- trigger_data->carrier_link_up = netif_carrier_ok(trigger_data->net_dev);
+ trigger_data->carrier_link_up = netif_running(trigger_data->net_dev) &&
+ netif_carrier_ok(trigger_data->net_dev);
if (!trigger_data->carrier_link_up)
return;
--
2.42.0
Powered by blists - more mailing lists