diff options
author | Jes Sorensen <jes@sgi.com> | 2006-02-06 17:12:43 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-20 16:42:58 -0500 |
commit | 58383af629efb07e5a0694e445eda0c65b16e1de (patch) | |
tree | 228369b2e56411c91ee1356957c0aa2dc0d033e5 /fs | |
parent | 8b5536bbee53620f8d5f367987e5727ba36d886d (diff) |
[PATCH] kobj_map semaphore to mutex conversion
Convert the kobj_map code to use a mutex instead of a semaphore. It
converts the single two users as well, genhd.c and char_dev.c.
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs')
-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 | ||