aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2006-02-06 17:12:43 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 16:42:58 -0500
commit58383af629efb07e5a0694e445eda0c65b16e1de (patch)
tree228369b2e56411c91ee1356957c0aa2dc0d033e5 /block/genhd.c
parent8b5536bbee53620f8d5f367987e5727ba36d886d (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 'block/genhd.c')
-rw-r--r--block/genhd.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/block/genhd.c b/block/genhd.c
index db57546a709d..64510fd88621 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -15,12 +15,13 @@
15#include <linux/kmod.h> 15#include <linux/kmod.h>
16#include <linux/kobj_map.h> 16#include <linux/kobj_map.h>
17#include <linux/buffer_head.h> 17#include <linux/buffer_head.h>
18#include <linux/mutex.h>
18 19
19#define MAX_PROBE_HASH 255 /* random */ 20#define MAX_PROBE_HASH 255 /* random */
20 21
21static struct subsystem block_subsys; 22static struct subsystem block_subsys;
22 23
23static DECLARE_MUTEX(block_subsys_sem); 24static DEFINE_MUTEX(block_subsys_lock);
24 25
25/* 26/*
26 * Can be deleted altogether. Later. 27 * Can be deleted altogether. Later.
@@ -46,7 +47,7 @@ struct blkdev_info {
46/* 47/*
47 * iterate over a list of blkdev_info structures. allows 48 * iterate over a list of blkdev_info structures. allows
48 * the major_names array to be iterated over from outside this file 49 * the major_names array to be iterated over from outside this file
49 * must be called with the block_subsys_sem held 50 * must be called with the block_subsys_lock held
50 */ 51 */
51void *get_next_blkdev(void *dev) 52void *get_next_blkdev(void *dev)
52{ 53{
@@ -85,20 +86,20 @@ out:
85 86
86void *acquire_blkdev_list(void) 87void *acquire_blkdev_list(void)
87{ 88{
88 down(&block_subsys_sem); 89 mutex_lock(&block_subsys_lock);
89 return get_next_blkdev(NULL); 90 return get_next_blkdev(NULL);
90} 91}
91 92
92void release_blkdev_list(void *dev) 93void release_blkdev_list(void *dev)
93{ 94{
94 up(&block_subsys_sem); 95 mutex_unlock(&block_subsys_lock);
95 kfree(dev); 96 kfree(dev);
96} 97}
97 98
98 99
99/* 100/*
100 * Count the number of records in the blkdev_list. 101 * Count the number of records in the blkdev_list.
101 * must be called with the block_subsys_sem held 102 * must be called with the block_subsys_lock held
102 */ 103 */
103int count_blkdev_list(void) 104int count_blkdev_list(void)
104{ 105{
@@ -118,7 +119,7 @@ int count_blkdev_list(void)
118/* 119/*
119 * extract the major and name values from a blkdev_info struct 120 * extract the major and name values from a blkdev_info struct
120 * passed in as a void to *dev. Must be called with 121 * passed in as a void to *dev. Must be called with
121 * block_subsys_sem held 122 * block_subsys_lock held
122 */ 123 */
123int get_blkdev_info(void *dev, int *major, char **name) 124int get_blkdev_info(void *dev, int *major, char **name)
124{ 125{
@@ -138,7 +139,7 @@ int register_blkdev(unsigned int major, const char *name)
138 struct blk_major_name **n, *p; 139 struct blk_major_name **n, *p;
139 int index, ret = 0; 140 int index, ret = 0;
140 141
141 down(&block_subsys_sem); 142 mutex_lock(&block_subsys_lock);
142 143
143 /* temporary */ 144 /* temporary */
144 if (major == 0) { 145 if (major == 0) {
@@ -183,7 +184,7 @@ int register_blkdev(unsigned int major, const char *name)
183 kfree(p); 184 kfree(p);
184 } 185 }
185out: 186out:
186 up(&block_subsys_sem); 187 mutex_unlock(&block_subsys_lock);
187 return ret; 188 return ret;
188} 189}
189 190
@@ -197,7 +198,7 @@ int unregister_blkdev(unsigned int major, const char *name)
197 int index = major_to_index(major); 198 int index = major_to_index(major);
198 int ret = 0; 199 int ret = 0;
199 200
200 down(&block_subsys_sem); 201 mutex_lock(&block_subsys_lock);
201 for (n = &major_names[index]; *n; n = &(*n)->next) 202 for (n = &major_names[index]; *n; n = &(*n)->next)
202 if ((*n)->major == major) 203 if ((*n)->major == major)
203 break; 204 break;
@@ -207,7 +208,7 @@ int unregister_blkdev(unsigned int major, const char *name)
207 p = *n; 208 p = *n;
208 *n = p->next; 209 *n = p->next;
209 } 210 }
210 up(&block_subsys_sem); 211 mutex_unlock(&block_subsys_lock);
211 kfree(p); 212 kfree(p);
212 213
213 return ret; 214 return ret;
@@ -301,7 +302,7 @@ static void *part_start(struct seq_file *part, loff_t *pos)
301 struct list_head *p; 302 struct list_head *p;
302 loff_t l = *pos; 303 loff_t l = *pos;
303 304
304 down(&block_subsys_sem); 305 mutex_lock(&block_subsys_lock);
305 list_for_each(p, &block_subsys.kset.list) 306 list_for_each(p, &block_subsys.kset.list)
306 if (!l--) 307 if (!l--)
307 return list_entry(p, struct gendisk, kobj.entry); 308 return list_entry(p, struct gendisk, kobj.entry);
@@ -318,7 +319,7 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos)
318 319
319static void part_stop(struct seq_file *part, void *v) 320static void part_stop(struct seq_file *part, void *v)
320{ 321{
321 up(&block_subsys_sem); 322 mutex_unlock(&block_subsys_lock);
322} 323}
323 324
324static int show_partition(struct seq_file *part, void *v) 325static int show_partition(struct seq_file *part, void *v)
@@ -377,7 +378,7 @@ static struct kobject *base_probe(dev_t dev, int *part, void *data)
377 378
378static int __init genhd_device_init(void) 379static int __init genhd_device_init(void)
379{ 380{
380 bdev_map = kobj_map_init(base_probe, &block_subsys_sem); 381 bdev_map = kobj_map_init(base_probe, &block_subsys_lock);
381 blk_dev_init(); 382 blk_dev_init();
382 subsystem_register(&block_subsys); 383 subsystem_register(&block_subsys);
383 return 0; 384 return 0;
@@ -611,7 +612,7 @@ static void *diskstats_start(struct seq_file *part, loff_t *pos)
611 loff_t k = *pos; 612 loff_t k = *pos;
612 struct list_head *p; 613 struct list_head *p;
613 614
614 down(&block_subsys_sem); 615 mutex_lock(&block_subsys_lock);
615 list_for_each(p, &block_subsys.kset.list) 616 list_for_each(p, &block_subsys.kset.list)
616 if (!k--) 617 if (!k--)
617 return list_entry(p, struct gendisk, kobj.entry); 618 return list_entry(p, struct gendisk, kobj.entry);
@@ -628,7 +629,7 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
628 629
629static void diskstats_stop(struct seq_file *part, void *v) 630static void diskstats_stop(struct seq_file *part, void *v)
630{ 631{
631 up(&block_subsys_sem); 632 mutex_unlock(&block_subsys_lock);
632} 633}
633 634
634static int diskstats_show(struct seq_file *s, void *v) 635static int diskstats_show(struct seq_file *s, void *v)