aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-03-23 06:00:21 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 10:38:10 -0500
commit8ed965d612d9e9bc08805c75123f063cf6966311 (patch)
tree7a863b9cb0d408295193f888b06d40d3364a404a /drivers
parent9cdf18279d1f4a2d075ebe924d74e6e4547f6e1b (diff)
[PATCH] sem2mutex: drivers: raw, connector, dcdbas, ppp_generic
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/raw.c23
-rw-r--r--drivers/connector/connector.c15
-rw-r--r--drivers/firmware/dcdbas.c23
-rw-r--r--drivers/net/ppp_generic.c25
4 files changed, 45 insertions, 41 deletions
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 30e4cbe16bb0..15a7b4086524 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -19,6 +19,7 @@
19#include <linux/uio.h> 19#include <linux/uio.h>
20#include <linux/cdev.h> 20#include <linux/cdev.h>
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/mutex.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24 25
@@ -29,7 +30,7 @@ struct raw_device_data {
29 30
30static struct class *raw_class; 31static struct class *raw_class;
31static struct raw_device_data raw_devices[MAX_RAW_MINORS]; 32static struct raw_device_data raw_devices[MAX_RAW_MINORS];
32static DECLARE_MUTEX(raw_mutex); 33static DEFINE_MUTEX(raw_mutex);
33static struct file_operations raw_ctl_fops; /* forward declaration */ 34static struct file_operations raw_ctl_fops; /* forward declaration */
34 35
35/* 36/*
@@ -53,7 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp)
53 return 0; 54 return 0;
54 } 55 }
55 56
56 down(&raw_mutex); 57 mutex_lock(&raw_mutex);
57 58
58 /* 59 /*
59 * All we need to do on open is check that the device is bound. 60 * All we need to do on open is check that the device is bound.
@@ -78,7 +79,7 @@ static int raw_open(struct inode *inode, struct file *filp)
78 filp->f_dentry->d_inode->i_mapping = 79 filp->f_dentry->d_inode->i_mapping =
79 bdev->bd_inode->i_mapping; 80 bdev->bd_inode->i_mapping;
80 filp->private_data = bdev; 81 filp->private_data = bdev;
81 up(&raw_mutex); 82 mutex_unlock(&raw_mutex);
82 return 0; 83 return 0;
83 84
84out2: 85out2:
@@ -86,7 +87,7 @@ out2:
86out1: 87out1:
87 blkdev_put(bdev); 88 blkdev_put(bdev);
88out: 89out:
89 up(&raw_mutex); 90 mutex_unlock(&raw_mutex);
90 return err; 91 return err;
91} 92}
92 93
@@ -99,14 +100,14 @@ static int raw_release(struct inode *inode, struct file *filp)
99 const int minor= iminor(inode); 100 const int minor= iminor(inode);
100 struct block_device *bdev; 101 struct block_device *bdev;
101 102
102 down(&raw_mutex); 103 mutex_lock(&raw_mutex);
103 bdev = raw_devices[minor].binding; 104 bdev = raw_devices[minor].binding;
104 if (--raw_devices[minor].inuse == 0) { 105 if (--raw_devices[minor].inuse == 0) {
105 /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ 106 /* Here inode->i_mapping == bdev->bd_inode->i_mapping */
106 inode->i_mapping = &inode->i_data; 107 inode->i_mapping = &inode->i_data;
107 inode->i_mapping->backing_dev_info = &default_backing_dev_info; 108 inode->i_mapping->backing_dev_info = &default_backing_dev_info;
108 } 109 }
109 up(&raw_mutex); 110 mutex_unlock(&raw_mutex);
110 111
111 bd_release(bdev); 112 bd_release(bdev);
112 blkdev_put(bdev); 113 blkdev_put(bdev);
@@ -187,9 +188,9 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
187 goto out; 188 goto out;
188 } 189 }
189 190
190 down(&raw_mutex); 191 mutex_lock(&raw_mutex);
191 if (rawdev->inuse) { 192 if (rawdev->inuse) {
192 up(&raw_mutex); 193 mutex_unlock(&raw_mutex);
193 err = -EBUSY; 194 err = -EBUSY;
194 goto out; 195 goto out;
195 } 196 }
@@ -211,11 +212,11 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
211 bind_device(&rq); 212 bind_device(&rq);
212 } 213 }
213 } 214 }
214 up(&raw_mutex); 215 mutex_unlock(&raw_mutex);
215 } else { 216 } else {
216 struct block_device *bdev; 217 struct block_device *bdev;
217 218
218 down(&raw_mutex); 219 mutex_lock(&raw_mutex);
219 bdev = rawdev->binding; 220 bdev = rawdev->binding;
220 if (bdev) { 221 if (bdev) {
221 rq.block_major = MAJOR(bdev->bd_dev); 222 rq.block_major = MAJOR(bdev->bd_dev);
@@ -223,7 +224,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
223 } else { 224 } else {
224 rq.block_major = rq.block_minor = 0; 225 rq.block_major = rq.block_minor = 0;
225 } 226 }
226 up(&raw_mutex); 227 mutex_unlock(&raw_mutex);
227 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) { 228 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) {
228 err = -EFAULT; 229 err = -EFAULT;
229 goto out; 230 goto out;
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index d7125f4d9113..35897079a78d 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -26,6 +26,7 @@
26#include <linux/netlink.h> 26#include <linux/netlink.h>
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/connector.h> 28#include <linux/connector.h>
29#include <linux/mutex.h>
29 30
30#include <net/sock.h> 31#include <net/sock.h>
31 32
@@ -41,7 +42,7 @@ module_param(cn_val, uint, 0);
41MODULE_PARM_DESC(cn_idx, "Connector's main device idx."); 42MODULE_PARM_DESC(cn_idx, "Connector's main device idx.");
42MODULE_PARM_DESC(cn_val, "Connector's main device val."); 43MODULE_PARM_DESC(cn_val, "Connector's main device val.");
43 44
44static DECLARE_MUTEX(notify_lock); 45static DEFINE_MUTEX(notify_lock);
45static LIST_HEAD(notify_list); 46static LIST_HEAD(notify_list);
46 47
47static struct cn_dev cdev; 48static struct cn_dev cdev;
@@ -260,7 +261,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event)
260{ 261{
261 struct cn_ctl_entry *ent; 262 struct cn_ctl_entry *ent;
262 263
263 down(&notify_lock); 264 mutex_lock(&notify_lock);
264 list_for_each_entry(ent, &notify_list, notify_entry) { 265 list_for_each_entry(ent, &notify_list, notify_entry) {
265 int i; 266 int i;
266 struct cn_notify_req *req; 267 struct cn_notify_req *req;
@@ -293,7 +294,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event)
293 cn_netlink_send(&m, ctl->group, GFP_KERNEL); 294 cn_netlink_send(&m, ctl->group, GFP_KERNEL);
294 } 295 }
295 } 296 }
296 up(&notify_lock); 297 mutex_unlock(&notify_lock);
297} 298}
298 299
299/* 300/*
@@ -407,14 +408,14 @@ static void cn_callback(void *data)
407 if (ctl->group == 0) { 408 if (ctl->group == 0) {
408 struct cn_ctl_entry *n; 409 struct cn_ctl_entry *n;
409 410
410 down(&notify_lock); 411 mutex_lock(&notify_lock);
411 list_for_each_entry_safe(ent, n, &notify_list, notify_entry) { 412 list_for_each_entry_safe(ent, n, &notify_list, notify_entry) {
412 if (cn_ctl_msg_equals(ent->msg, ctl)) { 413 if (cn_ctl_msg_equals(ent->msg, ctl)) {
413 list_del(&ent->notify_entry); 414 list_del(&ent->notify_entry);
414 kfree(ent); 415 kfree(ent);
415 } 416 }
416 } 417 }
417 up(&notify_lock); 418 mutex_unlock(&notify_lock);
418 419
419 return; 420 return;
420 } 421 }
@@ -429,9 +430,9 @@ static void cn_callback(void *data)
429 430
430 memcpy(ent->msg, ctl, size - sizeof(*ent)); 431 memcpy(ent->msg, ctl, size - sizeof(*ent));
431 432
432 down(&notify_lock); 433 mutex_lock(&notify_lock);
433 list_add(&ent->notify_entry, &notify_list); 434 list_add(&ent->notify_entry, &notify_list);
434 up(&notify_lock); 435 mutex_unlock(&notify_lock);
435} 436}
436 437
437static int __init cn_init(void) 438static int __init cn_init(void)
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 3a4e5c5b4e1f..d6543fc4a923 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -33,6 +33,7 @@
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/types.h> 35#include <linux/types.h>
36#include <linux/mutex.h>
36#include <asm/io.h> 37#include <asm/io.h>
37#include <asm/semaphore.h> 38#include <asm/semaphore.h>
38 39
@@ -48,7 +49,7 @@ static u8 *smi_data_buf;
48static dma_addr_t smi_data_buf_handle; 49static dma_addr_t smi_data_buf_handle;
49static unsigned long smi_data_buf_size; 50static unsigned long smi_data_buf_size;
50static u32 smi_data_buf_phys_addr; 51static u32 smi_data_buf_phys_addr;
51static DECLARE_MUTEX(smi_data_lock); 52static DEFINE_MUTEX(smi_data_lock);
52 53
53static unsigned int host_control_action; 54static unsigned int host_control_action;
54static unsigned int host_control_smi_type; 55static unsigned int host_control_smi_type;
@@ -139,9 +140,9 @@ static ssize_t smi_data_buf_size_store(struct device *dev,
139 buf_size = simple_strtoul(buf, NULL, 10); 140 buf_size = simple_strtoul(buf, NULL, 10);
140 141
141 /* make sure SMI data buffer is at least buf_size */ 142 /* make sure SMI data buffer is at least buf_size */
142 down(&smi_data_lock); 143 mutex_lock(&smi_data_lock);
143 ret = smi_data_buf_realloc(buf_size); 144 ret = smi_data_buf_realloc(buf_size);
144 up(&smi_data_lock); 145 mutex_unlock(&smi_data_lock);
145 if (ret) 146 if (ret)
146 return ret; 147 return ret;
147 148
@@ -154,7 +155,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos,
154 size_t max_read; 155 size_t max_read;
155 ssize_t ret; 156 ssize_t ret;
156 157
157 down(&smi_data_lock); 158 mutex_lock(&smi_data_lock);
158 159
159 if (pos >= smi_data_buf_size) { 160 if (pos >= smi_data_buf_size) {
160 ret = 0; 161 ret = 0;
@@ -165,7 +166,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos,
165 ret = min(max_read, count); 166 ret = min(max_read, count);
166 memcpy(buf, smi_data_buf + pos, ret); 167 memcpy(buf, smi_data_buf + pos, ret);
167out: 168out:
168 up(&smi_data_lock); 169 mutex_unlock(&smi_data_lock);
169 return ret; 170 return ret;
170} 171}
171 172
@@ -174,7 +175,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
174{ 175{
175 ssize_t ret; 176 ssize_t ret;
176 177
177 down(&smi_data_lock); 178 mutex_lock(&smi_data_lock);
178 179
179 ret = smi_data_buf_realloc(pos + count); 180 ret = smi_data_buf_realloc(pos + count);
180 if (ret) 181 if (ret)
@@ -183,7 +184,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
183 memcpy(smi_data_buf + pos, buf, count); 184 memcpy(smi_data_buf + pos, buf, count);
184 ret = count; 185 ret = count;
185out: 186out:
186 up(&smi_data_lock); 187 mutex_unlock(&smi_data_lock);
187 return ret; 188 return ret;
188} 189}
189 190
@@ -201,9 +202,9 @@ static ssize_t host_control_action_store(struct device *dev,
201 ssize_t ret; 202 ssize_t ret;
202 203
203 /* make sure buffer is available for host control command */ 204 /* make sure buffer is available for host control command */
204 down(&smi_data_lock); 205 mutex_lock(&smi_data_lock);
205 ret = smi_data_buf_realloc(sizeof(struct apm_cmd)); 206 ret = smi_data_buf_realloc(sizeof(struct apm_cmd));
206 up(&smi_data_lock); 207 mutex_unlock(&smi_data_lock);
207 if (ret) 208 if (ret)
208 return ret; 209 return ret;
209 210
@@ -302,7 +303,7 @@ static ssize_t smi_request_store(struct device *dev,
302 unsigned long val = simple_strtoul(buf, NULL, 10); 303 unsigned long val = simple_strtoul(buf, NULL, 10);
303 ssize_t ret; 304 ssize_t ret;
304 305
305 down(&smi_data_lock); 306 mutex_lock(&smi_data_lock);
306 307
307 if (smi_data_buf_size < sizeof(struct smi_cmd)) { 308 if (smi_data_buf_size < sizeof(struct smi_cmd)) {
308 ret = -ENODEV; 309 ret = -ENODEV;
@@ -334,7 +335,7 @@ static ssize_t smi_request_store(struct device *dev,
334 } 335 }
335 336
336out: 337out:
337 up(&smi_data_lock); 338 mutex_unlock(&smi_data_lock);
338 return ret; 339 return ret;
339} 340}
340 341
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index f608c12e3e8b..b2073fce8216 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -46,6 +46,7 @@
46#include <linux/rwsem.h> 46#include <linux/rwsem.h>
47#include <linux/stddef.h> 47#include <linux/stddef.h>
48#include <linux/device.h> 48#include <linux/device.h>
49#include <linux/mutex.h>
49#include <net/slhc_vj.h> 50#include <net/slhc_vj.h>
50#include <asm/atomic.h> 51#include <asm/atomic.h>
51 52
@@ -198,11 +199,11 @@ static unsigned int cardmap_find_first_free(struct cardmap *map);
198static void cardmap_destroy(struct cardmap **map); 199static void cardmap_destroy(struct cardmap **map);
199 200
200/* 201/*
201 * all_ppp_sem protects the all_ppp_units mapping. 202 * all_ppp_mutex protects the all_ppp_units mapping.
202 * It also ensures that finding a ppp unit in the all_ppp_units map 203 * It also ensures that finding a ppp unit in the all_ppp_units map
203 * and updating its file.refcnt field is atomic. 204 * and updating its file.refcnt field is atomic.
204 */ 205 */
205static DECLARE_MUTEX(all_ppp_sem); 206static DEFINE_MUTEX(all_ppp_mutex);
206static struct cardmap *all_ppp_units; 207static struct cardmap *all_ppp_units;
207static atomic_t ppp_unit_count = ATOMIC_INIT(0); 208static atomic_t ppp_unit_count = ATOMIC_INIT(0);
208 209
@@ -804,7 +805,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
804 /* Attach to an existing ppp unit */ 805 /* Attach to an existing ppp unit */
805 if (get_user(unit, p)) 806 if (get_user(unit, p))
806 break; 807 break;
807 down(&all_ppp_sem); 808 mutex_lock(&all_ppp_mutex);
808 err = -ENXIO; 809 err = -ENXIO;
809 ppp = ppp_find_unit(unit); 810 ppp = ppp_find_unit(unit);
810 if (ppp != 0) { 811 if (ppp != 0) {
@@ -812,7 +813,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
812 file->private_data = &ppp->file; 813 file->private_data = &ppp->file;
813 err = 0; 814 err = 0;
814 } 815 }
815 up(&all_ppp_sem); 816 mutex_unlock(&all_ppp_mutex);
816 break; 817 break;
817 818
818 case PPPIOCATTCHAN: 819 case PPPIOCATTCHAN:
@@ -2446,7 +2447,7 @@ ppp_create_interface(int unit, int *retp)
2446 dev->do_ioctl = ppp_net_ioctl; 2447 dev->do_ioctl = ppp_net_ioctl;
2447 2448
2448 ret = -EEXIST; 2449 ret = -EEXIST;
2449 down(&all_ppp_sem); 2450 mutex_lock(&all_ppp_mutex);
2450 if (unit < 0) 2451 if (unit < 0)
2451 unit = cardmap_find_first_free(all_ppp_units); 2452 unit = cardmap_find_first_free(all_ppp_units);
2452 else if (cardmap_get(all_ppp_units, unit) != NULL) 2453 else if (cardmap_get(all_ppp_units, unit) != NULL)
@@ -2465,12 +2466,12 @@ ppp_create_interface(int unit, int *retp)
2465 2466
2466 atomic_inc(&ppp_unit_count); 2467 atomic_inc(&ppp_unit_count);
2467 cardmap_set(&all_ppp_units, unit, ppp); 2468 cardmap_set(&all_ppp_units, unit, ppp);
2468 up(&all_ppp_sem); 2469 mutex_unlock(&all_ppp_mutex);
2469 *retp = 0; 2470 *retp = 0;
2470 return ppp; 2471 return ppp;
2471 2472
2472out2: 2473out2:
2473 up(&all_ppp_sem); 2474 mutex_unlock(&all_ppp_mutex);
2474 free_netdev(dev); 2475 free_netdev(dev);
2475out1: 2476out1:
2476 kfree(ppp); 2477 kfree(ppp);
@@ -2500,7 +2501,7 @@ static void ppp_shutdown_interface(struct ppp *ppp)
2500{ 2501{
2501 struct net_device *dev; 2502 struct net_device *dev;
2502 2503
2503 down(&all_ppp_sem); 2504 mutex_lock(&all_ppp_mutex);
2504 ppp_lock(ppp); 2505 ppp_lock(ppp);
2505 dev = ppp->dev; 2506 dev = ppp->dev;
2506 ppp->dev = NULL; 2507 ppp->dev = NULL;
@@ -2514,7 +2515,7 @@ static void ppp_shutdown_interface(struct ppp *ppp)
2514 ppp->file.dead = 1; 2515 ppp->file.dead = 1;
2515 ppp->owner = NULL; 2516 ppp->owner = NULL;
2516 wake_up_interruptible(&ppp->file.rwait); 2517 wake_up_interruptible(&ppp->file.rwait);
2517 up(&all_ppp_sem); 2518 mutex_unlock(&all_ppp_mutex);
2518} 2519}
2519 2520
2520/* 2521/*
@@ -2556,7 +2557,7 @@ static void ppp_destroy_interface(struct ppp *ppp)
2556 2557
2557/* 2558/*
2558 * Locate an existing ppp unit. 2559 * Locate an existing ppp unit.
2559 * The caller should have locked the all_ppp_sem. 2560 * The caller should have locked the all_ppp_mutex.
2560 */ 2561 */
2561static struct ppp * 2562static struct ppp *
2562ppp_find_unit(int unit) 2563ppp_find_unit(int unit)
@@ -2601,7 +2602,7 @@ ppp_connect_channel(struct channel *pch, int unit)
2601 int ret = -ENXIO; 2602 int ret = -ENXIO;
2602 int hdrlen; 2603 int hdrlen;
2603 2604
2604 down(&all_ppp_sem); 2605 mutex_lock(&all_ppp_mutex);
2605 ppp = ppp_find_unit(unit); 2606 ppp = ppp_find_unit(unit);
2606 if (ppp == 0) 2607 if (ppp == 0)
2607 goto out; 2608 goto out;
@@ -2626,7 +2627,7 @@ ppp_connect_channel(struct channel *pch, int unit)
2626 outl: 2627 outl:
2627 write_unlock_bh(&pch->upl); 2628 write_unlock_bh(&pch->upl);
2628 out: 2629 out:
2629 up(&all_ppp_sem); 2630 mutex_unlock(&all_ppp_mutex);
2630 return ret; 2631 return ret;
2631} 2632}
2632 2633