diff options
Diffstat (limited to 'net/atm/resources.c')
-rw-r--r-- | net/atm/resources.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/net/atm/resources.c b/net/atm/resources.c index 224190537c90..18ac80698f83 100644 --- a/net/atm/resources.c +++ b/net/atm/resources.c | |||
@@ -18,6 +18,8 @@ | |||
18 | #include <linux/bitops.h> | 18 | #include <linux/bitops.h> |
19 | #include <linux/capability.h> | 19 | #include <linux/capability.h> |
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/mutex.h> | ||
22 | |||
21 | #include <net/sock.h> /* for struct sock */ | 23 | #include <net/sock.h> /* for struct sock */ |
22 | 24 | ||
23 | #include "common.h" | 25 | #include "common.h" |
@@ -26,7 +28,7 @@ | |||
26 | 28 | ||
27 | 29 | ||
28 | LIST_HEAD(atm_devs); | 30 | LIST_HEAD(atm_devs); |
29 | DECLARE_MUTEX(atm_dev_mutex); | 31 | DEFINE_MUTEX(atm_dev_mutex); |
30 | 32 | ||
31 | static struct atm_dev *__alloc_atm_dev(const char *type) | 33 | static struct atm_dev *__alloc_atm_dev(const char *type) |
32 | { | 34 | { |
@@ -65,9 +67,9 @@ struct atm_dev *atm_dev_lookup(int number) | |||
65 | { | 67 | { |
66 | struct atm_dev *dev; | 68 | struct atm_dev *dev; |
67 | 69 | ||
68 | down(&atm_dev_mutex); | 70 | mutex_lock(&atm_dev_mutex); |
69 | dev = __atm_dev_lookup(number); | 71 | dev = __atm_dev_lookup(number); |
70 | up(&atm_dev_mutex); | 72 | mutex_unlock(&atm_dev_mutex); |
71 | return dev; | 73 | return dev; |
72 | } | 74 | } |
73 | 75 | ||
@@ -83,11 +85,11 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, | |||
83 | type); | 85 | type); |
84 | return NULL; | 86 | return NULL; |
85 | } | 87 | } |
86 | down(&atm_dev_mutex); | 88 | mutex_lock(&atm_dev_mutex); |
87 | if (number != -1) { | 89 | if (number != -1) { |
88 | if ((inuse = __atm_dev_lookup(number))) { | 90 | if ((inuse = __atm_dev_lookup(number))) { |
89 | atm_dev_put(inuse); | 91 | atm_dev_put(inuse); |
90 | up(&atm_dev_mutex); | 92 | mutex_unlock(&atm_dev_mutex); |
91 | kfree(dev); | 93 | kfree(dev); |
92 | return NULL; | 94 | return NULL; |
93 | } | 95 | } |
@@ -112,12 +114,12 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, | |||
112 | printk(KERN_ERR "atm_dev_register: " | 114 | printk(KERN_ERR "atm_dev_register: " |
113 | "atm_proc_dev_register failed for dev %s\n", | 115 | "atm_proc_dev_register failed for dev %s\n", |
114 | type); | 116 | type); |
115 | up(&atm_dev_mutex); | 117 | mutex_unlock(&atm_dev_mutex); |
116 | kfree(dev); | 118 | kfree(dev); |
117 | return NULL; | 119 | return NULL; |
118 | } | 120 | } |
119 | list_add_tail(&dev->dev_list, &atm_devs); | 121 | list_add_tail(&dev->dev_list, &atm_devs); |
120 | up(&atm_dev_mutex); | 122 | mutex_unlock(&atm_dev_mutex); |
121 | 123 | ||
122 | return dev; | 124 | return dev; |
123 | } | 125 | } |
@@ -133,9 +135,9 @@ void atm_dev_deregister(struct atm_dev *dev) | |||
133 | * with same number can appear, such we need deregister proc, | 135 | * with same number can appear, such we need deregister proc, |
134 | * release async all vccs and remove them from vccs list too | 136 | * release async all vccs and remove them from vccs list too |
135 | */ | 137 | */ |
136 | down(&atm_dev_mutex); | 138 | mutex_lock(&atm_dev_mutex); |
137 | list_del(&dev->dev_list); | 139 | list_del(&dev->dev_list); |
138 | up(&atm_dev_mutex); | 140 | mutex_unlock(&atm_dev_mutex); |
139 | 141 | ||
140 | atm_dev_release_vccs(dev); | 142 | atm_dev_release_vccs(dev); |
141 | atm_proc_dev_deregister(dev); | 143 | atm_proc_dev_deregister(dev); |
@@ -196,16 +198,16 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg) | |||
196 | return -EFAULT; | 198 | return -EFAULT; |
197 | if (get_user(len, &iobuf->length)) | 199 | if (get_user(len, &iobuf->length)) |
198 | return -EFAULT; | 200 | return -EFAULT; |
199 | down(&atm_dev_mutex); | 201 | mutex_lock(&atm_dev_mutex); |
200 | list_for_each(p, &atm_devs) | 202 | list_for_each(p, &atm_devs) |
201 | size += sizeof(int); | 203 | size += sizeof(int); |
202 | if (size > len) { | 204 | if (size > len) { |
203 | up(&atm_dev_mutex); | 205 | mutex_unlock(&atm_dev_mutex); |
204 | return -E2BIG; | 206 | return -E2BIG; |
205 | } | 207 | } |
206 | tmp_buf = kmalloc(size, GFP_ATOMIC); | 208 | tmp_buf = kmalloc(size, GFP_ATOMIC); |
207 | if (!tmp_buf) { | 209 | if (!tmp_buf) { |
208 | up(&atm_dev_mutex); | 210 | mutex_unlock(&atm_dev_mutex); |
209 | return -ENOMEM; | 211 | return -ENOMEM; |
210 | } | 212 | } |
211 | tmp_p = tmp_buf; | 213 | tmp_p = tmp_buf; |
@@ -213,7 +215,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg) | |||
213 | dev = list_entry(p, struct atm_dev, dev_list); | 215 | dev = list_entry(p, struct atm_dev, dev_list); |
214 | *tmp_p++ = dev->number; | 216 | *tmp_p++ = dev->number; |
215 | } | 217 | } |
216 | up(&atm_dev_mutex); | 218 | mutex_unlock(&atm_dev_mutex); |
217 | error = ((copy_to_user(buf, tmp_buf, size)) || | 219 | error = ((copy_to_user(buf, tmp_buf, size)) || |
218 | put_user(size, &iobuf->length)) | 220 | put_user(size, &iobuf->length)) |
219 | ? -EFAULT : 0; | 221 | ? -EFAULT : 0; |
@@ -400,13 +402,13 @@ static __inline__ void *dev_get_idx(loff_t left) | |||
400 | 402 | ||
401 | void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos) | 403 | void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos) |
402 | { | 404 | { |
403 | down(&atm_dev_mutex); | 405 | mutex_lock(&atm_dev_mutex); |
404 | return *pos ? dev_get_idx(*pos) : (void *) 1; | 406 | return *pos ? dev_get_idx(*pos) : (void *) 1; |
405 | } | 407 | } |
406 | 408 | ||
407 | void atm_dev_seq_stop(struct seq_file *seq, void *v) | 409 | void atm_dev_seq_stop(struct seq_file *seq, void *v) |
408 | { | 410 | { |
409 | up(&atm_dev_mutex); | 411 | mutex_unlock(&atm_dev_mutex); |
410 | } | 412 | } |
411 | 413 | ||
412 | void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 414 | void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) |