diff options
author | Jaroslav Kysela <perex@suse.cz> | 2006-03-22 05:02:08 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-03-22 05:02:08 -0500 |
commit | 5501972e0b5857bc8354770d900ceb9b40c7f6b7 (patch) | |
tree | ff239422827c4cd54d2998f8851304255de31b38 /fs/char_dev.c | |
parent | 9d2f928ddf64ca0361562e30faf584cd33055c60 (diff) | |
parent | e952f31bce6e9f64db01f607abc46529ba57ac9e (diff) |
Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Diffstat (limited to 'fs/char_dev.c')
-rw-r--r-- | fs/char_dev.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/char_dev.c b/fs/char_dev.c index 21195c481637..5c36345c9bf7 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/kobject.h> | 19 | #include <linux/kobject.h> |
20 | #include <linux/kobj_map.h> | 20 | #include <linux/kobj_map.h> |
21 | #include <linux/cdev.h> | 21 | #include <linux/cdev.h> |
22 | #include <linux/mutex.h> | ||
22 | 23 | ||
23 | #ifdef CONFIG_KMOD | 24 | #ifdef CONFIG_KMOD |
24 | #include <linux/kmod.h> | 25 | #include <linux/kmod.h> |
@@ -28,7 +29,7 @@ static struct kobj_map *cdev_map; | |||
28 | 29 | ||
29 | #define MAX_PROBE_HASH 255 /* random */ | 30 | #define MAX_PROBE_HASH 255 /* random */ |
30 | 31 | ||
31 | static DECLARE_MUTEX(chrdevs_lock); | 32 | static DEFINE_MUTEX(chrdevs_lock); |
32 | 33 | ||
33 | static struct char_device_struct { | 34 | static struct char_device_struct { |
34 | struct char_device_struct *next; | 35 | struct char_device_struct *next; |
@@ -88,13 +89,13 @@ out: | |||
88 | 89 | ||
89 | void *acquire_chrdev_list(void) | 90 | void *acquire_chrdev_list(void) |
90 | { | 91 | { |
91 | down(&chrdevs_lock); | 92 | mutex_lock(&chrdevs_lock); |
92 | return get_next_chrdev(NULL); | 93 | return get_next_chrdev(NULL); |
93 | } | 94 | } |
94 | 95 | ||
95 | void release_chrdev_list(void *dev) | 96 | void release_chrdev_list(void *dev) |
96 | { | 97 | { |
97 | up(&chrdevs_lock); | 98 | mutex_unlock(&chrdevs_lock); |
98 | kfree(dev); | 99 | kfree(dev); |
99 | } | 100 | } |
100 | 101 | ||
@@ -151,7 +152,7 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, | |||
151 | 152 | ||
152 | memset(cd, 0, sizeof(struct char_device_struct)); | 153 | memset(cd, 0, sizeof(struct char_device_struct)); |
153 | 154 | ||
154 | down(&chrdevs_lock); | 155 | mutex_lock(&chrdevs_lock); |
155 | 156 | ||
156 | /* temporary */ | 157 | /* temporary */ |
157 | if (major == 0) { | 158 | if (major == 0) { |
@@ -186,10 +187,10 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, | |||
186 | } | 187 | } |
187 | cd->next = *cp; | 188 | cd->next = *cp; |
188 | *cp = cd; | 189 | *cp = cd; |
189 | up(&chrdevs_lock); | 190 | mutex_unlock(&chrdevs_lock); |
190 | return cd; | 191 | return cd; |
191 | out: | 192 | out: |
192 | up(&chrdevs_lock); | 193 | mutex_unlock(&chrdevs_lock); |
193 | kfree(cd); | 194 | kfree(cd); |
194 | return ERR_PTR(ret); | 195 | return ERR_PTR(ret); |
195 | } | 196 | } |
@@ -200,7 +201,7 @@ __unregister_chrdev_region(unsigned major, unsigned baseminor, int minorct) | |||
200 | struct char_device_struct *cd = NULL, **cp; | 201 | struct char_device_struct *cd = NULL, **cp; |
201 | int i = major_to_index(major); | 202 | int i = major_to_index(major); |
202 | 203 | ||
203 | down(&chrdevs_lock); | 204 | mutex_lock(&chrdevs_lock); |
204 | for (cp = &chrdevs[i]; *cp; cp = &(*cp)->next) | 205 | for (cp = &chrdevs[i]; *cp; cp = &(*cp)->next) |
205 | if ((*cp)->major == major && | 206 | if ((*cp)->major == major && |
206 | (*cp)->baseminor == baseminor && | 207 | (*cp)->baseminor == baseminor && |
@@ -210,7 +211,7 @@ __unregister_chrdev_region(unsigned major, unsigned baseminor, int minorct) | |||
210 | cd = *cp; | 211 | cd = *cp; |
211 | *cp = cd->next; | 212 | *cp = cd->next; |
212 | } | 213 | } |
213 | up(&chrdevs_lock); | 214 | mutex_unlock(&chrdevs_lock); |
214 | return cd; | 215 | return cd; |
215 | } | 216 | } |
216 | 217 | ||