diff options
author | Nate Case <ncase@xes-inc.com> | 2008-01-29 11:05:09 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-03 07:28:41 -0500 |
commit | 35b5f6b1a82b5c586e0b24c711dc6ba944e88ef1 (patch) | |
tree | cf08793802ce8f91f13e262c3b6cdcf0a01d95e9 /drivers/net/phy/phy_device.c | |
parent | 2b91213064bd882c3adf35f028c6d12fab3269ec (diff) |
PHYLIB: Locking fixes for PHY I/O potentially sleeping
PHY read/write functions can potentially sleep (e.g., a PHY accessed
via I2C). The following changes were made to account for this:
* Change spin locks to mutex locks
* Add a BUG_ON() to phy_read() phy_write() to warn against
calling them from an interrupt context.
* Use work queue for PHY state machine handling since
it can potentially sleep
* Change phydev lock from spinlock to mutex
Signed-off-by: Nate Case <ncase@xes-inc.com>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r-- | drivers/net/phy/phy_device.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 5b9e1751e1b4..f4c4fd85425f 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
26 | #include <linux/etherdevice.h> | 26 | #include <linux/etherdevice.h> |
27 | #include <linux/skbuff.h> | 27 | #include <linux/skbuff.h> |
28 | #include <linux/spinlock.h> | ||
29 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
30 | #include <linux/module.h> | 29 | #include <linux/module.h> |
31 | #include <linux/mii.h> | 30 | #include <linux/mii.h> |
@@ -80,7 +79,7 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) | |||
80 | 79 | ||
81 | dev->state = PHY_DOWN; | 80 | dev->state = PHY_DOWN; |
82 | 81 | ||
83 | spin_lock_init(&dev->lock); | 82 | mutex_init(&dev->lock); |
84 | 83 | ||
85 | return dev; | 84 | return dev; |
86 | } | 85 | } |
@@ -656,7 +655,7 @@ static int phy_probe(struct device *dev) | |||
656 | if (!(phydrv->flags & PHY_HAS_INTERRUPT)) | 655 | if (!(phydrv->flags & PHY_HAS_INTERRUPT)) |
657 | phydev->irq = PHY_POLL; | 656 | phydev->irq = PHY_POLL; |
658 | 657 | ||
659 | spin_lock_bh(&phydev->lock); | 658 | mutex_lock(&phydev->lock); |
660 | 659 | ||
661 | /* Start out supporting everything. Eventually, | 660 | /* Start out supporting everything. Eventually, |
662 | * a controller will attach, and may modify one | 661 | * a controller will attach, and may modify one |
@@ -670,7 +669,7 @@ static int phy_probe(struct device *dev) | |||
670 | if (phydev->drv->probe) | 669 | if (phydev->drv->probe) |
671 | err = phydev->drv->probe(phydev); | 670 | err = phydev->drv->probe(phydev); |
672 | 671 | ||
673 | spin_unlock_bh(&phydev->lock); | 672 | mutex_unlock(&phydev->lock); |
674 | 673 | ||
675 | return err; | 674 | return err; |
676 | 675 | ||
@@ -682,9 +681,9 @@ static int phy_remove(struct device *dev) | |||
682 | 681 | ||
683 | phydev = to_phy_device(dev); | 682 | phydev = to_phy_device(dev); |
684 | 683 | ||
685 | spin_lock_bh(&phydev->lock); | 684 | mutex_lock(&phydev->lock); |
686 | phydev->state = PHY_DOWN; | 685 | phydev->state = PHY_DOWN; |
687 | spin_unlock_bh(&phydev->lock); | 686 | mutex_unlock(&phydev->lock); |
688 | 687 | ||
689 | if (phydev->drv->remove) | 688 | if (phydev->drv->remove) |
690 | phydev->drv->remove(phydev); | 689 | phydev->drv->remove(phydev); |