diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2008-06-13 16:34:53 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2008-06-13 16:34:53 +1000 |
commit | c3d9eb43992ad23c2b04b1d179cf93ba0e69f086 (patch) | |
tree | cf90f37fe318ded39bca227fb903a362007aba33 | |
parent | b1644c2cf251e1a51b1f42b81a24891660f44690 (diff) | |
parent | e05c6daff0066a22c4f5dd2e7e3223288c9011bb (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
-rw-r--r-- | arch/arm/mach-lh7a40x/clocks.c | 15 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 21 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 15 | ||||
-rw-r--r-- | drivers/net/ppp_async.c | 8 | ||||
-rw-r--r-- | drivers/net/ps3_gelic_net.c | 1 | ||||
-rw-r--r-- | drivers/net/ps3_gelic_wireless.c | 1 | ||||
-rw-r--r-- | drivers/pci/hotplug/ibmphp_hpc.c | 30 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_def.h | 1 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_os.c | 4 | ||||
-rw-r--r-- | include/net/bluetooth/hci_core.h | 7 | ||||
-rw-r--r-- | net/9p/trans_virtio.c | 21 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 2 | ||||
-rw-r--r-- | sound/soc/s3c24xx/s3c2443-ac97.c | 11 |
13 files changed, 72 insertions, 65 deletions
diff --git a/arch/arm/mach-lh7a40x/clocks.c b/arch/arm/mach-lh7a40x/clocks.c index 7530a95c15a6..4119f7ec3cfe 100644 --- a/arch/arm/mach-lh7a40x/clocks.c +++ b/arch/arm/mach-lh7a40x/clocks.c @@ -12,6 +12,7 @@ #include <asm/hardware.h> #include <asm/arch/clocks.h> #include <linux/err.h> +#include <linux/spinlock.h> struct module; struct icst525_params; @@ -80,14 +81,14 @@ unsigned int pclkfreq_get (void) /* ----- */ static LIST_HEAD(clocks); -static DECLARE_MUTEX(clocks_sem); +static DEFINE_SPINLOCK(clocks_lock); struct clk *clk_get (struct device *dev, const char *id) { struct clk *p; struct clk *clk = ERR_PTR(-ENOENT); - down (&clocks_sem); + spin_lock(&clocks_lock); list_for_each_entry (p, &clocks, node) { if (strcmp (id, p->name) == 0 && try_module_get(p->owner)) { @@ -95,7 +96,7 @@ struct clk *clk_get (struct device *dev, const char *id) break; } } - up (&clocks_sem); + spin_unlock(&clocks_lock); return clk; } @@ -175,18 +176,18 @@ static struct clk clcd_clk = { int clk_register (struct clk *clk) { - down (&clocks_sem); + spin_lock(&clocks_lock); list_add (&clk->node, &clocks); - up (&clocks_sem); + spin_unlock(&clocks_lock); return 0; } EXPORT_SYMBOL(clk_register); void clk_unregister (struct clk *clk) { - down (&clocks_sem); + spin_lock(&clocks_lock); list_del (&clk->node); - up (&clocks_sem); + spin_unlock(&clocks_lock); } EXPORT_SYMBOL(clk_unregister); 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; diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index ea13baa3851b..5ebc33d300d2 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -25,6 +25,7 @@ #ifndef __HCI_CORE_H #define __HCI_CORE_H +#include <linux/mutex.h> #include <net/bluetooth/hci.h> /* HCI upper protocols */ @@ -115,7 +116,7 @@ struct hci_dev { struct sk_buff *sent_cmd; struct sk_buff *reassembly[3]; - struct semaphore req_lock; + struct mutex req_lock; wait_queue_head_t req_wait_q; __u32 req_status; __u32 req_result; @@ -657,8 +658,8 @@ struct hci_sec_filter { #define HCI_REQ_PEND 1 #define HCI_REQ_CANCELED 2 -#define hci_req_lock(d) down(&d->req_lock) -#define hci_req_unlock(d) up(&d->req_lock) +#define hci_req_lock(d) mutex_lock(&d->req_lock) +#define hci_req_unlock(d) mutex_unlock(&d->req_lock) void hci_req_complete(struct hci_dev *hdev, int result); diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 42adc052b149..a6084becf971 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -34,6 +34,7 @@ #include <linux/ipv6.h> #include <linux/errno.h> #include <linux/kernel.h> +#include <linux/spinlock.h> #include <linux/un.h> #include <linux/uaccess.h> #include <linux/inet.h> @@ -48,8 +49,8 @@ #define VIRTQUEUE_NUM 128 -/* a single mutex to manage channel initialization and attachment */ -static DEFINE_MUTEX(virtio_9p_lock); +/* a single lock to manage channel initialization and attachment */ +static DEFINE_SPINLOCK(virtio_9p_lock); /* global which tracks highest initialized channel */ static int chan_index; @@ -211,9 +212,9 @@ static void p9_virtio_close(struct p9_trans *trans) chan->max_tag = 0; spin_unlock_irqrestore(&chan->lock, flags); - mutex_lock(&virtio_9p_lock); + spin_lock(&virtio_9p_lock); chan->inuse = false; - mutex_unlock(&virtio_9p_lock); + spin_unlock(&virtio_9p_lock); kfree(trans); } @@ -381,10 +382,10 @@ static int p9_virtio_probe(struct virtio_device *vdev) struct virtio_chan *chan; int index; - mutex_lock(&virtio_9p_lock); + spin_lock(&virtio_9p_lock); index = chan_index++; chan = &channels[index]; - mutex_unlock(&virtio_9p_lock); + spin_unlock(&virtio_9p_lock); if (chan_index > MAX_9P_CHAN) { printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n"); @@ -413,9 +414,9 @@ static int p9_virtio_probe(struct virtio_device *vdev) out_free_vq: vdev->config->del_vq(chan->vq); fail: - mutex_lock(&virtio_9p_lock); + spin_lock(&virtio_9p_lock); chan_index--; - mutex_unlock(&virtio_9p_lock); + spin_unlock(&virtio_9p_lock); return err; } @@ -449,7 +450,7 @@ p9_virtio_create(const char *devname, char *args, int msize, struct virtio_chan *chan = channels; int index = 0; - mutex_lock(&virtio_9p_lock); + spin_lock(&virtio_9p_lock); while (index < MAX_9P_CHAN) { if (chan->initialized && !chan->inuse) { chan->inuse = true; @@ -459,7 +460,7 @@ p9_virtio_create(const char *devname, char *args, int msize, chan = &channels[index]; } } - mutex_unlock(&virtio_9p_lock); + spin_unlock(&virtio_9p_lock); if (index >= MAX_9P_CHAN) { printk(KERN_ERR "9p: no channels available\n"); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index aec6929f5c16..7c07cef47e1f 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -875,7 +875,7 @@ int hci_register_dev(struct hci_dev *hdev) hdev->reassembly[i] = NULL; init_waitqueue_head(&hdev->req_wait_q); - init_MUTEX(&hdev->req_lock); + mutex_init(&hdev->req_lock); inquiry_cache_init(hdev); diff --git a/sound/soc/s3c24xx/s3c2443-ac97.c b/sound/soc/s3c24xx/s3c2443-ac97.c index 533565b61b2f..b219215ad121 100644 --- a/sound/soc/s3c24xx/s3c2443-ac97.c +++ b/sound/soc/s3c24xx/s3c2443-ac97.c @@ -20,6 +20,7 @@ #include <linux/wait.h> #include <linux/delay.h> #include <linux/clk.h> +#include <linux/mutex.h> #include <sound/core.h> #include <sound/pcm.h> @@ -46,7 +47,7 @@ static struct s3c24xx_ac97_info s3c24xx_ac97; static DECLARE_COMPLETION(ac97_completion); static u32 codec_ready; -static DECLARE_MUTEX(ac97_mutex); +static DEFINE_MUTEX(ac97_mutex); static unsigned short s3c2443_ac97_read(struct snd_ac97 *ac97, unsigned short reg) @@ -55,7 +56,7 @@ static unsigned short s3c2443_ac97_read(struct snd_ac97 *ac97, u32 ac_codec_cmd; u32 stat, addr, data; - down(&ac97_mutex); + mutex_lock(&ac97_mutex); codec_ready = S3C_AC97_GLBSTAT_CODECREADY; ac_codec_cmd = readl(s3c24xx_ac97.regs + S3C_AC97_CODEC_CMD); @@ -78,7 +79,7 @@ static unsigned short s3c2443_ac97_read(struct snd_ac97 *ac97, printk(KERN_ERR "s3c24xx-ac97: req addr = %02x," " rep addr = %02x\n", reg, addr); - up(&ac97_mutex); + mutex_unlock(&ac97_mutex); return (unsigned short)data; } @@ -89,7 +90,7 @@ static void s3c2443_ac97_write(struct snd_ac97 *ac97, unsigned short reg, u32 ac_glbctrl; u32 ac_codec_cmd; - down(&ac97_mutex); + mutex_lock(&ac97_mutex); codec_ready = S3C_AC97_GLBSTAT_CODECREADY; ac_codec_cmd = readl(s3c24xx_ac97.regs + S3C_AC97_CODEC_CMD); @@ -108,7 +109,7 @@ static void s3c2443_ac97_write(struct snd_ac97 *ac97, unsigned short reg, ac_codec_cmd |= S3C_AC97_CODEC_CMD_READ; writel(ac_codec_cmd, s3c24xx_ac97.regs + S3C_AC97_CODEC_CMD); - up(&ac97_mutex); + mutex_unlock(&ac97_mutex); } |