Skip to content

Commit

Permalink
phylib: Allow early-out in phy_change
Browse files Browse the repository at this point in the history
Marvell 88E1121R Dual PHY device can be hardware-configured
to use shared interrupt pin for both PHY ports. For such
PHY configurations using shared PHY interrupt phy_interrupt()
handler will also schedule a work for PHY port which didn't
cause an interrupt.

This patch adds a possibility for PHY drivers to provide
did_interrupt() function which reports if the PHY (or a PHY
port in a multi-PHY device) generated an interrupt. This
function is called in phy_change() as phy_change() shouldn't
proceed if it is invoked for a PHY which didn't cause an
interrupt. So check for interrupt originator in phy_change()
to allow early-out.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Anatolij Gustschin authored and David S. Miller committed Apr 13, 2009
1 parent 140bc92 commit a8729eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,10 @@ static void phy_change(struct work_struct *work)
struct phy_device *phydev =
container_of(work, struct phy_device, phy_queue);

if (phydev->drv->did_interrupt &&
!phydev->drv->did_interrupt(phydev))
goto ignore;

err = phy_disable_interrupts(phydev);

if (err)
Expand All @@ -681,6 +685,11 @@ static void phy_change(struct work_struct *work)

return;

ignore:
atomic_dec(&phydev->irq_disable);
enable_irq(phydev->irq);
return;

irq_enable_err:
disable_irq(phydev->irq);
atomic_inc(&phydev->irq_disable);
Expand Down
6 changes: 6 additions & 0 deletions include/linux/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ struct phy_driver {
/* Enables or disables interrupts */
int (*config_intr)(struct phy_device *phydev);

/*
* Checks if the PHY generated an interrupt.
* For multi-PHY devices with shared PHY interrupt pin
*/
int (*did_interrupt)(struct phy_device *phydev);

/* Clears up any memory if needed */
void (*remove)(struct phy_device *phydev);

Expand Down

0 comments on commit a8729eb

Please sign in to comment.