From: Stephen Hemminger Convert sky2 driver phy semaphore to a mutex. Signed-off-by: Stephen Hemminger Signed-off-by: Andrew Morton --- drivers/net/sky2.c | 31 ++++++++++++++++--------------- drivers/net/sky2.h | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff -puN drivers/net/sky2.c~sky2-use-mutex drivers/net/sky2.c --- devel/drivers/net/sky2.c~sky2-use-mutex 2006-03-16 02:07:40.000000000 -0800 +++ devel-akpm/drivers/net/sky2.c 2006-03-16 02:07:40.000000000 -0800 @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -504,9 +505,9 @@ static void sky2_phy_init(struct sky2_hw /* Force a renegotiation */ static void sky2_phy_reinit(struct sky2_port *sky2) { - down(&sky2->phy_sema); + mutex_lock(&sky2->phy_mutex); sky2_phy_init(sky2->hw, sky2->port); - up(&sky2->phy_sema); + mutex_unlock(&sky2->phy_mutex); } static void sky2_mac_init(struct sky2_hw *hw, unsigned port) @@ -571,9 +572,9 @@ static void sky2_mac_init(struct sky2_hw sky2_read16(hw, SK_REG(port, GMAC_IRQ_SRC)); - down(&sky2->phy_sema); + mutex_lock(&sky2->phy_mutex); sky2_phy_init(hw, port); - up(&sky2->phy_sema); + mutex_unlock(&sky2->phy_mutex); /* MIB clear */ reg = gma_read16(hw, port, GM_PHY_ADDR); @@ -886,9 +887,9 @@ static int sky2_ioctl(struct net_device case SIOCGMIIREG: { u16 val = 0; - down(&sky2->phy_sema); + mutex_lock(&sky2->phy_mutex); err = __gm_phy_read(hw, sky2->port, data->reg_num & 0x1f, &val); - up(&sky2->phy_sema); + mutex_unlock(&sky2->phy_mutex); data->val_out = val; break; @@ -898,10 +899,10 @@ static int sky2_ioctl(struct net_device if (!capable(CAP_NET_ADMIN)) return -EPERM; - down(&sky2->phy_sema); + mutex_lock(&sky2->phy_mutex); err = gm_phy_write(hw, sky2->port, data->reg_num & 0x1f, data->val_in); - up(&sky2->phy_sema); + mutex_unlock(&sky2->phy_mutex); break; } return err; @@ -1642,7 +1643,7 @@ static void sky2_phy_task(void *arg) struct sky2_hw *hw = sky2->hw; u16 istatus, phystat; - down(&sky2->phy_sema); + mutex_lock(&sky2->phy_mutex); istatus = gm_phy_read(hw, sky2->port, PHY_MARV_INT_STAT); phystat = gm_phy_read(hw, sky2->port, PHY_MARV_PHY_STAT); @@ -1670,7 +1671,7 @@ static void sky2_phy_task(void *arg) sky2_link_down(sky2); } out: - up(&sky2->phy_sema); + mutex_unlock(&sky2->phy_mutex); spin_lock_irq(&hw->hw_lock); hw->intr_mask |= (sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2; @@ -2743,7 +2744,7 @@ static int sky2_phys_id(struct net_devic ms = data * 1000; /* save initial values */ - down(&sky2->phy_sema); + mutex_lock(&sky2->phy_mutex); if (hw->chip_id == CHIP_ID_YUKON_XL) { u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); @@ -2759,9 +2760,9 @@ static int sky2_phys_id(struct net_devic sky2_led(hw, port, onoff); onoff = !onoff; - up(&sky2->phy_sema); + mutex_unlock(&sky2->phy_mutex); interrupted = msleep_interruptible(250); - down(&sky2->phy_sema); + mutex_lock(&sky2->phy_mutex); ms -= 250; } @@ -2776,7 +2777,7 @@ static int sky2_phys_id(struct net_devic gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); } - up(&sky2->phy_sema); + mutex_unlock(&sky2->phy_mutex); return 0; } @@ -3089,7 +3090,7 @@ static __devinit struct net_device *sky2 sky2->rx_csum = (hw->chip_id != CHIP_ID_YUKON_XL); INIT_WORK(&sky2->phy_task, sky2_phy_task, sky2); - init_MUTEX(&sky2->phy_sema); + mutex_init(&sky2->phy_mutex); sky2->tx_pending = TX_DEF_PENDING; sky2->rx_pending = is_ec_a1(hw) ? 8 : RX_DEF_PENDING; sky2->rx_bufsize = sky2_buf_size(ETH_DATA_LEN); diff -puN drivers/net/sky2.h~sky2-use-mutex drivers/net/sky2.h --- devel/drivers/net/sky2.h~sky2-use-mutex 2006-03-16 02:07:40.000000000 -0800 +++ devel-akpm/drivers/net/sky2.h 2006-03-16 02:07:40.000000000 -0800 @@ -1870,7 +1870,7 @@ struct sky2_port { struct net_device_stats net_stats; struct work_struct phy_task; - struct semaphore phy_sema; + struct mutex phy_mutex; }; struct sky2_hw { _