Skip to content

Commit 34d884e

Browse files
hkallweitdavem330
authored andcommitted
net: phy: improve and inline phy_change
Now that phy_mac_interrupt() doesn't call phy_change() any longer it's called from phy_interrupt() only. Therefore phy_interrupt_is_valid() returns true always and the check can be removed. In case of PHY_HALTED phy_interrupt() bails out immediately, therefore the second check for PHY_HALTED including the call to phy_disable_interrupts() can be removed. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d73a215 commit 34d884e

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

drivers/net/phy/phy.c

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -722,41 +722,12 @@ static int phy_disable_interrupts(struct phy_device *phydev)
722722
return phy_clear_interrupt(phydev);
723723
}
724724

725-
/**
726-
* phy_change - Called by the phy_interrupt to handle PHY changes
727-
* @phydev: phy_device struct that interrupted
728-
*/
729-
static irqreturn_t phy_change(struct phy_device *phydev)
730-
{
731-
if (phy_interrupt_is_valid(phydev)) {
732-
if (phydev->drv->did_interrupt &&
733-
!phydev->drv->did_interrupt(phydev))
734-
return IRQ_NONE;
735-
736-
if (phydev->state == PHY_HALTED)
737-
if (phy_disable_interrupts(phydev))
738-
goto phy_err;
739-
}
740-
741-
/* reschedule state queue work to run as soon as possible */
742-
phy_trigger_machine(phydev);
743-
744-
if (phy_interrupt_is_valid(phydev) && phy_clear_interrupt(phydev))
745-
goto phy_err;
746-
return IRQ_HANDLED;
747-
748-
phy_err:
749-
phy_error(phydev);
750-
return IRQ_NONE;
751-
}
752-
753725
/**
754726
* phy_interrupt - PHY interrupt handler
755727
* @irq: interrupt line
756728
* @phy_dat: phy_device pointer
757729
*
758-
* Description: When a PHY interrupt occurs, the handler disables
759-
* interrupts, and uses phy_change to handle the interrupt.
730+
* Description: Handle PHY interrupt
760731
*/
761732
static irqreturn_t phy_interrupt(int irq, void *phy_dat)
762733
{
@@ -765,7 +736,19 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
765736
if (PHY_HALTED == phydev->state)
766737
return IRQ_NONE; /* It can't be ours. */
767738

768-
return phy_change(phydev);
739+
if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt(phydev))
740+
return IRQ_NONE;
741+
742+
/* reschedule state queue work to run as soon as possible */
743+
phy_trigger_machine(phydev);
744+
745+
if (phy_clear_interrupt(phydev))
746+
goto phy_err;
747+
return IRQ_HANDLED;
748+
749+
phy_err:
750+
phy_error(phydev);
751+
return IRQ_NONE;
769752
}
770753

771754
/**
@@ -846,7 +829,7 @@ void phy_stop(struct phy_device *phydev)
846829
phy_state_machine(&phydev->state_queue.work);
847830

848831
/* Cannot call flush_scheduled_work() here as desired because
849-
* of rtnl_lock(), but PHY_HALTED shall guarantee phy_change()
832+
* of rtnl_lock(), but PHY_HALTED shall guarantee irq handler
850833
* will not reenable interrupts.
851834
*/
852835
}

0 commit comments

Comments
 (0)