]> asedeno.scripts.mit.edu Git - linux.git/commit
net: phy: improve phy state checking
authorHeiner Kallweit <hkallweit1@gmail.com>
Sun, 16 Dec 2018 17:30:14 +0000 (18:30 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Dec 2018 23:11:07 +0000 (15:11 -0800)
commit2b3e88ea65287ba738a798622405b15344871085
tree41764dd927bc07f9fb481f08c6bb744c0dc43364
parent2429f13870d3d2abbe200807d0462272e16ec830
net: phy: improve phy state checking

Add helpers phy_is_started() and __phy_is_started() to avoid open-coded
checks whether PHY has been started. To make the check easier move
PHY_HALTED before PHY_UP in enum phy_state. Further improvements:

phy_start_aneg():
Return -EBUSY and print warning if function is called from a non-started
state (DOWN, READY, HALTED). Better check because function is exported
and drivers may use it incorrectly.

phy_interrupt():
Return IRQ_NONE also if state is DOWN or READY. We should never receive
an interrupt in one of these states, but better play safe.

phy_stop():
Just return and print a warning if PHY is in a non-started state.
This warning should help to identify drivers with unbalanced calls to
phy_start() / phy_stop().

phy_state_machine():
Schedule state machine run only if PHY is in a started state.
E.g. if state is READY we don't need the state machine, it will be
started by phy_start().

v2:
- don't use __func__ within phy_warn_state
v3:
- use WARN() instead of printing error message to facilitate debugging

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-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