[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZCZ3bSlOF9Sm4DJ2@ninjato>
Date: Fri, 31 Mar 2023 08:02:21 +0200
From: Wolfram Sang <wsa+renesas@...g-engineering.com>
To: Steen.Hegelund@...rochip.com
Cc: netdev@...r.kernel.org, linux-renesas-soc@...r.kernel.org,
steve.glendinning@...well.net, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
geert+renesas@...der.be, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net v4] smsc911x: only update stats when interface is up
> > + if (pdata->is_open) {
>
> Couldn't you just use netif_carrier_ok() here and drop the is_open
> variable?
From my research, I can't:
1) netif_carrier_ok() uses __LINK_STATE_NOCARRIER
2) __LINK_STATE_NOCARRIER gets cleared in netif_carrier_on()
3) netif_carrier_on() is this code:
if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
if (dev->reg_state == NETREG_UNINITIALIZED)
return;
atomic_inc(&dev->carrier_up_count);
linkwatch_fire_event(dev);
if (netif_running(dev))
__netdev_watchdog_up(dev);
}
4) Notice the last if. It checks netif_running(). So, it is possible to
have the carrier on and the device not opened yet.
5) Sadly, no cigar. If I didn't miss something...
But thanks for the suggestion! Happy hacking,
Wolfram
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists