diff options
author | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-03-21 14:05:45 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-03-21 14:05:45 -0500 |
commit | d04cdb64212eb5ae6a98026a97dda626e40e8e9a (patch) | |
tree | b6a7dbb21ccfceb915844e9a330b3d3dfcaf3c5b /drivers/base/map.c | |
parent | 2f8600dff2b140096a7df781884e918a16aa90e0 (diff) | |
parent | ec1248e70edc5cf7b485efcc7b41e44e10f422e5 (diff) |
Merge ../linux-2.6
Diffstat (limited to 'drivers/base/map.c')
-rw-r--r-- | drivers/base/map.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/base/map.c b/drivers/base/map.c index b449dae6f0d3..e87017f36853 100644 --- a/drivers/base/map.c +++ b/drivers/base/map.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/mutex.h> | ||
14 | #include <linux/kdev_t.h> | 15 | #include <linux/kdev_t.h> |
15 | #include <linux/kobject.h> | 16 | #include <linux/kobject.h> |
16 | #include <linux/kobj_map.h> | 17 | #include <linux/kobj_map.h> |
@@ -25,7 +26,7 @@ struct kobj_map { | |||
25 | int (*lock)(dev_t, void *); | 26 | int (*lock)(dev_t, void *); |
26 | void *data; | 27 | void *data; |
27 | } *probes[255]; | 28 | } *probes[255]; |
28 | struct semaphore *sem; | 29 | struct mutex *lock; |
29 | }; | 30 | }; |
30 | 31 | ||
31 | int kobj_map(struct kobj_map *domain, dev_t dev, unsigned long range, | 32 | int kobj_map(struct kobj_map *domain, dev_t dev, unsigned long range, |
@@ -53,7 +54,7 @@ int kobj_map(struct kobj_map *domain, dev_t dev, unsigned long range, | |||
53 | p->range = range; | 54 | p->range = range; |
54 | p->data = data; | 55 | p->data = data; |
55 | } | 56 | } |
56 | down(domain->sem); | 57 | mutex_lock(domain->lock); |
57 | for (i = 0, p -= n; i < n; i++, p++, index++) { | 58 | for (i = 0, p -= n; i < n; i++, p++, index++) { |
58 | struct probe **s = &domain->probes[index % 255]; | 59 | struct probe **s = &domain->probes[index % 255]; |
59 | while (*s && (*s)->range < range) | 60 | while (*s && (*s)->range < range) |
@@ -61,7 +62,7 @@ int kobj_map(struct kobj_map *domain, dev_t dev, unsigned long range, | |||
61 | p->next = *s; | 62 | p->next = *s; |
62 | *s = p; | 63 | *s = p; |
63 | } | 64 | } |
64 | up(domain->sem); | 65 | mutex_unlock(domain->lock); |
65 | return 0; | 66 | return 0; |
66 | } | 67 | } |
67 | 68 | ||
@@ -75,7 +76,7 @@ void kobj_unmap(struct kobj_map *domain, dev_t dev, unsigned long range) | |||
75 | if (n > 255) | 76 | if (n > 255) |
76 | n = 255; | 77 | n = 255; |
77 | 78 | ||
78 | down(domain->sem); | 79 | mutex_lock(domain->lock); |
79 | for (i = 0; i < n; i++, index++) { | 80 | for (i = 0; i < n; i++, index++) { |
80 | struct probe **s; | 81 | struct probe **s; |
81 | for (s = &domain->probes[index % 255]; *s; s = &(*s)->next) { | 82 | for (s = &domain->probes[index % 255]; *s; s = &(*s)->next) { |
@@ -88,7 +89,7 @@ void kobj_unmap(struct kobj_map *domain, dev_t dev, unsigned long range) | |||
88 | } | 89 | } |
89 | } | 90 | } |
90 | } | 91 | } |
91 | up(domain->sem); | 92 | mutex_unlock(domain->lock); |
92 | kfree(found); | 93 | kfree(found); |
93 | } | 94 | } |
94 | 95 | ||
@@ -99,7 +100,7 @@ struct kobject *kobj_lookup(struct kobj_map *domain, dev_t dev, int *index) | |||
99 | unsigned long best = ~0UL; | 100 | unsigned long best = ~0UL; |
100 | 101 | ||
101 | retry: | 102 | retry: |
102 | down(domain->sem); | 103 | mutex_lock(domain->lock); |
103 | for (p = domain->probes[MAJOR(dev) % 255]; p; p = p->next) { | 104 | for (p = domain->probes[MAJOR(dev) % 255]; p; p = p->next) { |
104 | struct kobject *(*probe)(dev_t, int *, void *); | 105 | struct kobject *(*probe)(dev_t, int *, void *); |
105 | struct module *owner; | 106 | struct module *owner; |
@@ -120,7 +121,7 @@ retry: | |||
120 | module_put(owner); | 121 | module_put(owner); |
121 | continue; | 122 | continue; |
122 | } | 123 | } |
123 | up(domain->sem); | 124 | mutex_unlock(domain->lock); |
124 | kobj = probe(dev, index, data); | 125 | kobj = probe(dev, index, data); |
125 | /* Currently ->owner protects _only_ ->probe() itself. */ | 126 | /* Currently ->owner protects _only_ ->probe() itself. */ |
126 | module_put(owner); | 127 | module_put(owner); |
@@ -128,11 +129,11 @@ retry: | |||
128 | return kobj; | 129 | return kobj; |
129 | goto retry; | 130 | goto retry; |
130 | } | 131 | } |
131 | up(domain->sem); | 132 | mutex_unlock(domain->lock); |
132 | return NULL; | 133 | return NULL; |
133 | } | 134 | } |
134 | 135 | ||
135 | struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem) | 136 | struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct mutex *lock) |
136 | { | 137 | { |
137 | struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL); | 138 | struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL); |
138 | struct probe *base = kzalloc(sizeof(*base), GFP_KERNEL); | 139 | struct probe *base = kzalloc(sizeof(*base), GFP_KERNEL); |
@@ -149,6 +150,6 @@ struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem) | |||
149 | base->get = base_probe; | 150 | base->get = base_probe; |
150 | for (i = 0; i < 255; i++) | 151 | for (i = 0; i < 255; i++) |
151 | p->probes[i] = base; | 152 | p->probes[i] = base; |
152 | p->sem = sem; | 153 | p->lock = lock; |
153 | return p; | 154 | return p; |
154 | } | 155 | } |