diff options
author | Arnd Bergmann <arnd@arndb.de> | 2006-10-08 18:08:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-10-17 17:46:32 -0400 |
commit | a9fc6338bd51a3d5735839e756fe7b741c2e6fad (patch) | |
tree | 0c75d1739bd65f21b125562dd9f603b1d195dd8c /drivers/usb/net/asix.c | |
parent | c41286fd42f3545513f8de9f61028120b6d38e89 (diff) |
usbnet: add a mutex around phy register access
When working on the mcs7830, I noticed the need for a mutex in its
mdio_read/mdio_write functions. A related problem seems to be present
in the asix driver in the respective functions.
This introduces a mutex in the common usbnet driver and uses it
from the two hardware specific drivers.
Acked-by: David Hollis <dhollis@davehollis.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/net/asix.c')
-rw-r--r-- | drivers/usb/net/asix.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c index 5edd0534c7a..881841e600d 100644 --- a/drivers/usb/net/asix.c +++ b/drivers/usb/net/asix.c | |||
@@ -569,10 +569,12 @@ static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) | |||
569 | struct usbnet *dev = netdev_priv(netdev); | 569 | struct usbnet *dev = netdev_priv(netdev); |
570 | u16 res; | 570 | u16 res; |
571 | 571 | ||
572 | mutex_lock(&dev->phy_mutex); | ||
572 | asix_set_sw_mii(dev); | 573 | asix_set_sw_mii(dev); |
573 | asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, | 574 | asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, |
574 | (__u16)loc, 2, (u16 *)&res); | 575 | (__u16)loc, 2, (u16 *)&res); |
575 | asix_set_hw_mii(dev); | 576 | asix_set_hw_mii(dev); |
577 | mutex_unlock(&dev->phy_mutex); | ||
576 | 578 | ||
577 | devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff)); | 579 | devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff)); |
578 | 580 | ||
@@ -586,10 +588,12 @@ asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val) | |||
586 | u16 res = cpu_to_le16(val); | 588 | u16 res = cpu_to_le16(val); |
587 | 589 | ||
588 | devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val); | 590 | devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val); |
591 | mutex_lock(&dev->phy_mutex); | ||
589 | asix_set_sw_mii(dev); | 592 | asix_set_sw_mii(dev); |
590 | asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, | 593 | asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, |
591 | (__u16)loc, 2, (u16 *)&res); | 594 | (__u16)loc, 2, (u16 *)&res); |
592 | asix_set_hw_mii(dev); | 595 | asix_set_hw_mii(dev); |
596 | mutex_unlock(&dev->phy_mutex); | ||
593 | } | 597 | } |
594 | 598 | ||
595 | /* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ | 599 | /* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ |