summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2008-06-04 14:50:59 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2008-06-04 14:50:59 +1000
commitc90b18a42b689aee00ac06c228dd3a47c0001567 (patch)
treedb1ad5fa29a8d822388e848293c430e659d575f5 /drivers
parent0bdc205d87af8fc8df46fe13fc3267c753badc85 (diff)
parente05c6daff0066a22c4f5dd2e7e3223288c9011bb (diff)
Merge commit 'semaphore-removal/semaphore-removal'
Conflicts: drivers/net/ps3_gelic_wireless.c drivers/scsi/qla2xxx/qla_attr.c drivers/scsi/qla2xxx/qla_def.h drivers/scsi/qla2xxx/qla_mbx.c drivers/scsi/qla2xxx/qla_mid.c drivers/scsi/qla2xxx/qla_os.c
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/bonding/bond_main.c21
-rw-r--r--drivers/net/bonding/bond_sysfs.c15
-rw-r--r--drivers/net/ppp_async.c8
-rw-r--r--drivers/net/ps3_gelic_net.c1
-rw-r--r--drivers/net/ps3_gelic_wireless.c1
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c30
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c4
8 files changed, 42 insertions, 39 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 5b4af3cc2a44..13307771b76a 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -38,6 +38,7 @@
#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/interrupt.h>
+#include <linux/mutex.h>
#include <linux/ptrace.h>
#include <linux/ioport.h>
#include <linux/in.h>
@@ -150,7 +151,7 @@ LIST_HEAD(bond_dev_list);
static struct proc_dir_entry *bond_proc_dir = NULL;
#endif
-extern struct rw_semaphore bonding_rwsem;
+extern struct mutex bonding_mutex;
static __be32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ;
static int arp_ip_count = 0;
static int bond_mode = BOND_MODE_ROUNDROBIN;
@@ -3502,10 +3503,10 @@ static int bond_event_changename(struct bonding *bond)
bond_remove_proc_entry(bond);
bond_create_proc_entry(bond);
#endif
- down_write(&(bonding_rwsem));
+ mutex_lock(&bonding_mutex);
bond_destroy_sysfs_entry(bond);
bond_create_sysfs_entry(bond);
- up_write(&(bonding_rwsem));
+ mutex_unlock(&bonding_mutex);
return NOTIFY_DONE;
}
@@ -4011,7 +4012,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
return -EPERM;
}
- down_write(&(bonding_rwsem));
+ mutex_lock(&bonding_mutex);
slave_dev = dev_get_by_name(&init_net, ifr->ifr_slave);
dprintk("slave_dev=%p: \n", slave_dev);
@@ -4044,7 +4045,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
dev_put(slave_dev);
}
- up_write(&(bonding_rwsem));
+ mutex_unlock(&bonding_mutex);
return res;
}
@@ -5023,7 +5024,7 @@ int bond_create(char *name, struct bond_params *params)
int res;
rtnl_lock();
- down_write(&bonding_rwsem);
+ mutex_lock(&bonding_mutex);
/* Check to see if the bond already exists. */
if (name) {
@@ -5072,12 +5073,12 @@ int bond_create(char *name, struct bond_params *params)
netif_carrier_off(bond_dev);
- up_write(&bonding_rwsem);
+ mutex_unlock(&bonding_mutex);
rtnl_unlock(); /* allows sysfs registration of net device */
res = bond_create_sysfs_entry(bond_dev->priv);
if (res < 0) {
rtnl_lock();
- down_write(&bonding_rwsem);
+ mutex_lock(&bonding_mutex);
bond_deinit(bond_dev);
unregister_netdevice(bond_dev);
goto out_rtnl;
@@ -5090,7 +5091,7 @@ out_bond:
out_netdev:
free_netdev(bond_dev);
out_rtnl:
- up_write(&bonding_rwsem);
+ mutex_unlock(&bonding_mutex);
rtnl_unlock();
return res;
}
@@ -5112,7 +5113,7 @@ static int __init bonding_init(void)
bond_create_proc_dir();
#endif
- init_rwsem(&bonding_rwsem);
+ mutex_init(&bonding_mutex);
for (i = 0; i < max_bonds; i++) {
res = bond_create(NULL, &bonding_defaults);
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index dd265c69b0df..d6d10fbbe7c7 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -30,6 +30,7 @@
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/in.h>
+#include <linux/mutex.h>
#include <linux/sysfs.h>
#include <linux/ctype.h>
#include <linux/inet.h>
@@ -64,7 +65,7 @@ static struct class *netdev_class;
* that we don't collide with an ongoing ioctl.
*/
-struct rw_semaphore bonding_rwsem;
+struct mutex bonding_mutex;
@@ -80,7 +81,7 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf)
int res = 0;
struct bonding *bond;
- down_read(&(bonding_rwsem));
+ mutex_lock(&bonding_mutex);
list_for_each_entry(bond, &bond_dev_list, bond_list) {
if (res > (PAGE_SIZE - IFNAMSIZ)) {
@@ -94,7 +95,7 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf)
}
if (res)
buf[res-1] = '\n'; /* eat the leftover space */
- up_read(&(bonding_rwsem));
+ mutex_unlock(&bonding_mutex);
return res;
}
@@ -132,7 +133,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
if (command[0] == '-') {
rtnl_lock();
- down_write(&bonding_rwsem);
+ mutex_lock(&bonding_mutex);
list_for_each_entry(bond, &bond_dev_list, bond_list)
if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) {
@@ -167,7 +168,7 @@ err_no_cmd:
return -EPERM;
out_unlock:
- up_write(&bonding_rwsem);
+ mutex_unlock(&bonding_mutex);
rtnl_unlock();
/* Always return either count or an error. If you return 0, you'll
@@ -262,7 +263,7 @@ static ssize_t bonding_store_slaves(struct device *d,
/* Note: We can't hold bond->lock here, as bond_create grabs it. */
rtnl_lock();
- down_write(&(bonding_rwsem));
+ mutex_lock(&bonding_mutex);
sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
ifname = command + 1;
@@ -379,7 +380,7 @@ err_no_cmd:
ret = -EPERM;
out:
- up_write(&(bonding_rwsem));
+ mutex_unlock(&bonding_mutex);
rtnl_unlock();
return ret;
}
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index f1a52def1241..26523cc2512d 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -67,7 +67,7 @@ struct asyncppp {
struct tasklet_struct tsk;
atomic_t refcnt;
- struct semaphore dead_sem;
+ struct completion death;
struct ppp_channel chan; /* interface to generic ppp layer */
unsigned char obuf[OBUFSIZE];
};
@@ -145,7 +145,7 @@ static struct asyncppp *ap_get(struct tty_struct *tty)
static void ap_put(struct asyncppp *ap)
{
if (atomic_dec_and_test(&ap->refcnt))
- up(&ap->dead_sem);
+ complete(&ap->death);
}
/*
@@ -182,7 +182,7 @@ ppp_asynctty_open(struct tty_struct *tty)
tasklet_init(&ap->tsk, ppp_async_process, (unsigned long) ap);
atomic_set(&ap->refcnt, 1);
- init_MUTEX_LOCKED(&ap->dead_sem);
+ init_completion(&ap->death);
ap->chan.private = ap;
ap->chan.ops = &async_ops;
@@ -229,7 +229,7 @@ ppp_asynctty_close(struct tty_struct *tty)
* by the time it returns.
*/
if (!atomic_dec_and_test(&ap->refcnt))
- down(&ap->dead_sem);
+ wait_for_completion(&ap->death);
tasklet_kill(&ap->tsk);
ppp_unregister_channel(&ap->chan);
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index 2eb54fd7bed5..e7963cc34f8c 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -30,6 +30,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index aa963ac1e37b..44e35df24db9 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -32,6 +32,7 @@
#include <linux/wireless.h>
#include <linux/ctype.h>
#include <linux/string.h>
+#include <linux/mutex.h>
#include <net/iw_handler.h>
#include <net/ieee80211.h>
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index 83f337c891a9..f061a06d8c63 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -102,9 +102,9 @@ static int to_debug = 0;
// global variables
//----------------------------------------------------------------------------
static struct mutex sem_hpcaccess; // lock access to HPC
-static struct semaphore semOperations; // lock all operations and
+static struct mutex mtx_operations; // lock all operations and
// access to data structures
-static struct semaphore sem_exit; // make sure polling thread goes away
+static struct completion exit_cmplt; // make sure polling thread goes away
static struct task_struct *ibmphp_poll_thread;
//----------------------------------------------------------------------------
// local function prototypes
@@ -132,8 +132,8 @@ void __init ibmphp_hpc_initvars (void)
debug ("%s - Entry\n", __func__);
mutex_init(&sem_hpcaccess);
- init_MUTEX (&semOperations);
- init_MUTEX_LOCKED (&sem_exit);
+ mutex_init(&mtx_operations);
+ init_completion(&exit_cmplt);
to_debug = 0;
debug ("%s - Exit\n", __func__);
@@ -794,7 +794,7 @@ void free_hpc_access (void)
*---------------------------------------------------------------------*/
void ibmphp_lock_operations (void)
{
- down (&semOperations);
+ mutex_lock(&mtx_operations);
to_debug = 1;
}
@@ -804,7 +804,7 @@ void ibmphp_lock_operations (void)
void ibmphp_unlock_operations (void)
{
debug ("%s - Entry\n", __func__);
- up (&semOperations);
+ mutex_unlock(&mtx_operations);
to_debug = 0;
debug ("%s - Exit\n", __func__);
}
@@ -831,7 +831,7 @@ static int poll_hpc(void *data)
while (!kthread_should_stop()) {
/* try to get the lock to do some kind of hardware access */
- down (&semOperations);
+ mutex_lock(&mtx_operations);
switch (poll_state) {
case POLL_LATCH_REGISTER:
@@ -886,13 +886,13 @@ static int poll_hpc(void *data)
break;
case POLL_SLEEP:
/* don't sleep with a lock on the hardware */
- up (&semOperations);
+ mutex_unlock(&mtx_operations);
msleep(POLL_INTERVAL_SEC * 1000);
if (kthread_should_stop())
break;
- down (&semOperations);
+ mutex_lock(&mtx_operations);
if (poll_count >= POLL_LATCH_CNT) {
poll_count = 0;
@@ -902,11 +902,11 @@ static int poll_hpc(void *data)
break;
}
/* give up the hardware semaphore */
- up (&semOperations);
+ mutex_unlock(&mtx_operations);
/* sleep for a short time just for good measure */
msleep(100);
}
- up (&sem_exit);
+ complete(&exit_cmplt);
debug ("%s - Exit\n", __func__);
return 0;
}
@@ -1075,9 +1075,9 @@ void __exit ibmphp_hpc_stop_poll_thread (void)
debug ("after locking operations \n");
// wait for poll thread to exit
- debug ("before sem_exit down \n");
- down (&sem_exit);
- debug ("after sem_exit down \n");
+ debug ("before sem_cmplt\n");
+ wait_for_completion(&exit_cmplt);
+ debug ("after sem_cmplt\n");
// cleanup
debug ("before free_hpc_access \n");
@@ -1085,8 +1085,6 @@ void __exit ibmphp_hpc_stop_poll_thread (void)
debug ("after free_hpc_access \n");
ibmphp_unlock_operations ();
debug ("after unlock operations \n");
- up (&sem_exit);
- debug ("after sem exit up\n");
debug ("%s - Exit\n", __func__);
}
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 8dd600013bd1..bb84ab0834a6 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -25,7 +25,6 @@
#include <linux/firmware.h>
#include <linux/aer.h>
#include <linux/mutex.h>
-#include <linux/semaphore.h>
#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 48eaa3bb5433..5511368efd16 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -2668,7 +2668,9 @@ qla2x00_request_firmware(scsi_qla_host_t *ha)
blob = &qla_fw_blobs[FW_ISP25XX];
}
- mutex_lock(&qla_fw_lock);
+ if (mutex_lock_killable(&qla_fw_lock))
+ return NULL;
+
if (blob->fw)
goto out;