net: phy: avoid kernel warning dump when stopping an errored PHY
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 22 May 2023 15:58:08 +0000 (16:58 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 May 2023 07:28:27 +0000 (08:28 +0100)
commit59088b5a946ee8a6603a9a84781670cedb01c40d
tree1aa6b3afb0cd87b4b09608d92c6a8aa51a704fb9
parent18731fe01d3de0721c7f6ba326e838a034d3114e
net: phy: avoid kernel warning dump when stopping an errored PHY

When taking a network interface down (or removing a SFP module) after
the PHY has encountered an error, phy_stop() complains incorrectly
that it was called from HALTED state.

The reason this is incorrect is that the network driver will have
called phy_start() when the interface was brought up, and the fact
that the PHY has a problem bears no relationship to the administrative
state of the interface. Taking the interface administratively down
(which calls phy_stop()) is always the right thing to do after a
successful phy_start() call, whether or not the PHY has encountered
an error.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy.c
include/linux/phy.h