From: Ingo Molnar Semaphore to mutexes conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar Cc: Ronald Bultje Cc: "David S. Miller" Cc: Jeff Garzik Cc: Yi Zhu Cc: James Ketrenos Signed-off-by: Andrew Morton --- drivers/net/cassini.c | 40 ++++++++++++++++++++-------------------- drivers/net/cassini.h | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff -puN drivers/net/cassini.c~sem2mutex-cassini drivers/net/cassini.c --- devel/drivers/net/cassini.c~sem2mutex-cassini 2006-01-17 18:22:22.000000000 -0800 +++ devel-akpm/drivers/net/cassini.c 2006-01-17 18:22:22.000000000 -0800 @@ -91,6 +91,7 @@ #include #include #include +#include #include @@ -3864,7 +3865,7 @@ static void cas_reset(struct cas *cp, in spin_unlock(&cp->stat_lock[N_TX_RINGS]); } -/* Shut down the chip, must be called with pm_sem held. */ +/* Shut down the chip, must be called with pm_mutex held. */ static void cas_shutdown(struct cas *cp) { unsigned long flags; @@ -4283,11 +4284,11 @@ static int cas_open(struct net_device *d int hw_was_up, err; unsigned long flags; - down(&cp->pm_sem); + mutex_lock(&cp->pm_mutex); hw_was_up = cp->hw_running; - /* The power-management semaphore protects the hw_running + /* The power-management mutex protects the hw_running * etc. state so it is safe to do this bit without cp->lock */ if (!cp->hw_running) { @@ -4336,7 +4337,7 @@ static int cas_open(struct net_device *d cas_unlock_all_restore(cp, flags); netif_start_queue(dev); - up(&cp->pm_sem); + mutex_unlock(&cp->pm_mutex); return 0; err_spare: @@ -4344,7 +4345,7 @@ err_spare: cas_free_rxds(cp); err_tx_tiny: cas_tx_tiny_free(cp); - up(&cp->pm_sem); + mutex_unlock(&cp->pm_mutex); return err; } @@ -4354,7 +4355,7 @@ static int cas_close(struct net_device * struct cas *cp = netdev_priv(dev); /* Make sure we don't get distracted by suspend/resume */ - down(&cp->pm_sem); + mutex_lock(&cp->pm_mutex); netif_stop_queue(dev); @@ -4371,7 +4372,7 @@ static int cas_close(struct net_device * cas_spare_free(cp); cas_free_rxds(cp); cas_tx_tiny_free(cp); - up(&cp->pm_sem); + mutex_unlock(&cp->pm_mutex); return 0; } @@ -4806,10 +4807,10 @@ static int cas_ioctl(struct net_device * unsigned long flags; int rc = -EOPNOTSUPP; - /* Hold the PM semaphore while doing ioctl's or we may collide + /* Hold the PM mutex while doing ioctl's or we may collide * with open/close and power management and oops. */ - down(&cp->pm_sem); + mutex_lock(&cp->pm_mutex); switch (cmd) { case SIOCGMIIPHY: /* Get address of MII PHY in use. */ data->phy_id = cp->phy_addr; @@ -4839,7 +4840,7 @@ static int cas_ioctl(struct net_device * break; }; - up(&cp->pm_sem); + mutex_unlock(&cp->pm_mutex); return rc; } @@ -4966,7 +4967,7 @@ static int __devinit cas_init_one(struct spin_lock_init(&cp->tx_lock[i]); } spin_lock_init(&cp->stat_lock[N_TX_RINGS]); - init_MUTEX(&cp->pm_sem); + mutex_init(&cp->pm_mutex); init_timer(&cp->link_timer); cp->link_timer.function = cas_link_timer; @@ -5088,10 +5089,10 @@ err_out_free_consistent: cp->init_block, cp->block_dvma); err_out_iounmap: - down(&cp->pm_sem); + mutex_lock(&cp->pm_mutex); if (cp->hw_running) cas_shutdown(cp); - up(&cp->pm_sem); + mutex_unlock(&cp->pm_mutex); iounmap(cp->regs); @@ -5124,11 +5125,11 @@ static void __devexit cas_remove_one(str cp = netdev_priv(dev); unregister_netdev(dev); - down(&cp->pm_sem); + mutex_lock(&cp->pm_mutex); flush_scheduled_work(); if (cp->hw_running) cas_shutdown(cp); - up(&cp->pm_sem); + mutex_unlock(&cp->pm_mutex); #if 1 if (cp->orig_cacheline_size) { @@ -5155,10 +5156,7 @@ static int cas_suspend(struct pci_dev *p struct cas *cp = netdev_priv(dev); unsigned long flags; - /* We hold the PM semaphore during entire driver - * sleep time - */ - down(&cp->pm_sem); + mutex_lock(&cp->pm_mutex); /* If the driver is opened, we stop the DMA */ if (cp->opened) { @@ -5178,6 +5176,7 @@ static int cas_suspend(struct pci_dev *p if (cp->hw_running) cas_shutdown(cp); + mutex_unlock(&cp->pm_mutex); return 0; } @@ -5189,6 +5188,7 @@ static int cas_resume(struct pci_dev *pd printk(KERN_INFO "%s: resuming\n", dev->name); + mutex_lock(&cp->pm_mutex); cas_hard_reset(cp); if (cp->opened) { unsigned long flags; @@ -5201,7 +5201,7 @@ static int cas_resume(struct pci_dev *pd netif_device_attach(dev); } - up(&cp->pm_sem); + mutex_unlock(&cp->pm_mutex); return 0; } #endif /* CONFIG_PM */ diff -puN drivers/net/cassini.h~sem2mutex-cassini drivers/net/cassini.h --- devel/drivers/net/cassini.h~sem2mutex-cassini 2006-01-17 18:22:22.000000000 -0800 +++ devel-akpm/drivers/net/cassini.h 2006-01-17 18:22:22.000000000 -0800 @@ -4284,7 +4284,7 @@ struct cas { * (ie. not power managed) */ int hw_running; int opened; - struct semaphore pm_sem; /* open/close/suspend/resume */ + struct mutex pm_mutex; /* open/close/suspend/resume */ struct cas_init_block *init_block; struct cas_tx_desc *init_txds[MAX_TX_RINGS]; _