Commit 3c507b8a authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

net: phy: add helper phy_polling_mode

Add a helper for checking whether polling is used to detect PHY status
changes.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d805f6a8
...@@ -525,7 +525,7 @@ static int phy_start_aneg_priv(struct phy_device *phydev, bool sync) ...@@ -525,7 +525,7 @@ static int phy_start_aneg_priv(struct phy_device *phydev, bool sync)
* negotiation may already be done and aneg interrupt may not be * negotiation may already be done and aneg interrupt may not be
* generated. * generated.
*/ */
if (phydev->irq != PHY_POLL && phydev->state == PHY_AN) { if (!phy_polling_mode(phydev) && phydev->state == PHY_AN) {
err = phy_aneg_done(phydev); err = phy_aneg_done(phydev);
if (err > 0) { if (err > 0) {
trigger = true; trigger = true;
...@@ -983,7 +983,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -983,7 +983,7 @@ void phy_state_machine(struct work_struct *work)
needs_aneg = true; needs_aneg = true;
break; break;
case PHY_NOLINK: case PHY_NOLINK:
if (phydev->irq != PHY_POLL) if (!phy_polling_mode(phydev))
break; break;
err = phy_read_status(phydev); err = phy_read_status(phydev);
...@@ -1024,7 +1024,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -1024,7 +1024,7 @@ void phy_state_machine(struct work_struct *work)
/* Only register a CHANGE if we are polling and link changed /* Only register a CHANGE if we are polling and link changed
* since latest checking. * since latest checking.
*/ */
if (phydev->irq == PHY_POLL) { if (phy_polling_mode(phydev)) {
old_link = phydev->link; old_link = phydev->link;
err = phy_read_status(phydev); err = phy_read_status(phydev);
if (err) if (err)
...@@ -1123,7 +1123,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -1123,7 +1123,7 @@ void phy_state_machine(struct work_struct *work)
* PHY, if PHY_IGNORE_INTERRUPT is set, then we will be moving * PHY, if PHY_IGNORE_INTERRUPT is set, then we will be moving
* between states from phy_mac_interrupt() * between states from phy_mac_interrupt()
*/ */
if (phydev->irq == PHY_POLL) if (phy_polling_mode(phydev))
queue_delayed_work(system_power_efficient_wq, &phydev->state_queue, queue_delayed_work(system_power_efficient_wq, &phydev->state_queue,
PHY_STATE_TIME * HZ); PHY_STATE_TIME * HZ);
} }
......
...@@ -824,6 +824,16 @@ static inline bool phy_interrupt_is_valid(struct phy_device *phydev) ...@@ -824,6 +824,16 @@ static inline bool phy_interrupt_is_valid(struct phy_device *phydev)
return phydev->irq != PHY_POLL && phydev->irq != PHY_IGNORE_INTERRUPT; return phydev->irq != PHY_POLL && phydev->irq != PHY_IGNORE_INTERRUPT;
} }
/**
* phy_polling_mode - Convenience function for testing whether polling is
* used to detect PHY status changes
* @phydev: the phy_device struct
*/
static inline bool phy_polling_mode(struct phy_device *phydev)
{
return phydev->irq == PHY_POLL;
}
/** /**
* phy_is_internal - Convenience function for testing if a PHY is internal * phy_is_internal - Convenience function for testing if a PHY is internal
* @phydev: the phy_device struct * @phydev: the phy_device struct
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment