aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 14:49:46 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 14:49:46 -0400
commitdd77a4ee0f3981693d4229aa1d57cea9e526ff47 (patch)
treecb486be20b950201103a03636cbb1e1d180f0098 /lib
parente8216dee838c09776680a6f1a2e54d81f3cdfa14 (diff)
parent7e9f4b2d3e21e87c26025810413ef1592834e63b (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (47 commits) Driver core: Don't call put methods while holding a spinlock Driver core: Remove unneeded routines from driver core Driver core: Fix potential deadlock in driver core PCI: enable driver multi-threaded probe Driver Core: add ability for drivers to do a threaded probe sysfs: add proper sysfs_init() prototype drivers/base: check errors drivers/base: Platform notify needs to occur before drivers attach to the device v4l-dev2: handle __must_check add CONFIG_ENABLE_MUST_CHECK add __must_check to device management code Driver core: fixed add_bind_files() definition Driver core: fix comments in drivers/base/power/resume.c sysfs_remove_bin_file: no return value, dump_stack on error kobject: must_check fixes Driver core: add ability for devices to create and remove bin files Class: add support for class interfaces for devices Driver core: create devices/virtual/ tree Driver core: add device_rename function Driver core: add ability for classes to handle devices properly ...
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug7
-rw-r--r--lib/klist.c26
-rw-r--r--lib/kobject.c9
3 files changed, 30 insertions, 12 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 3f21cc79a134..2869307ca3e4 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -8,6 +8,13 @@ config PRINTK_TIME
8 operations. This is useful for identifying long delays 8 operations. This is useful for identifying long delays
9 in kernel startup. 9 in kernel startup.
10 10
11config ENABLE_MUST_CHECK
12 bool "Enable __must_check logic"
13 default y
14 help
15 Enable the __must_check logic in the kernel build. Disable this to
16 suppress the "warning: ignoring return value of 'foo', declared with
17 attribute warn_unused_result" messages.
11 18
12config MAGIC_SYSRQ 19config MAGIC_SYSRQ
13 bool "Magic SysRq key" 20 bool "Magic SysRq key"
diff --git a/lib/klist.c b/lib/klist.c
index 9c94f0b163a1..120bd175aa78 100644
--- a/lib/klist.c
+++ b/lib/klist.c
@@ -123,12 +123,10 @@ EXPORT_SYMBOL_GPL(klist_add_tail);
123static void klist_release(struct kref * kref) 123static void klist_release(struct kref * kref)
124{ 124{
125 struct klist_node * n = container_of(kref, struct klist_node, n_ref); 125 struct klist_node * n = container_of(kref, struct klist_node, n_ref);
126 void (*put)(struct klist_node *) = n->n_klist->put; 126
127 list_del(&n->n_node); 127 list_del(&n->n_node);
128 complete(&n->n_removed); 128 complete(&n->n_removed);
129 n->n_klist = NULL; 129 n->n_klist = NULL;
130 if (put)
131 put(n);
132} 130}
133 131
134static int klist_dec_and_del(struct klist_node * n) 132static int klist_dec_and_del(struct klist_node * n)
@@ -145,10 +143,14 @@ static int klist_dec_and_del(struct klist_node * n)
145void klist_del(struct klist_node * n) 143void klist_del(struct klist_node * n)
146{ 144{
147 struct klist * k = n->n_klist; 145 struct klist * k = n->n_klist;
146 void (*put)(struct klist_node *) = k->put;
148 147
149 spin_lock(&k->k_lock); 148 spin_lock(&k->k_lock);
150 klist_dec_and_del(n); 149 if (!klist_dec_and_del(n))
150 put = NULL;
151 spin_unlock(&k->k_lock); 151 spin_unlock(&k->k_lock);
152 if (put)
153 put(n);
152} 154}
153 155
154EXPORT_SYMBOL_GPL(klist_del); 156EXPORT_SYMBOL_GPL(klist_del);
@@ -161,10 +163,7 @@ EXPORT_SYMBOL_GPL(klist_del);
161 163
162void klist_remove(struct klist_node * n) 164void klist_remove(struct klist_node * n)
163{ 165{
164 struct klist * k = n->n_klist; 166 klist_del(n);
165 spin_lock(&k->k_lock);
166 klist_dec_and_del(n);
167 spin_unlock(&k->k_lock);
168 wait_for_completion(&n->n_removed); 167 wait_for_completion(&n->n_removed);
169} 168}
170 169
@@ -260,12 +259,15 @@ static struct klist_node * to_klist_node(struct list_head * n)
260struct klist_node * klist_next(struct klist_iter * i) 259struct klist_node * klist_next(struct klist_iter * i)
261{ 260{
262 struct list_head * next; 261 struct list_head * next;
262 struct klist_node * lnode = i->i_cur;
263 struct klist_node * knode = NULL; 263 struct klist_node * knode = NULL;
264 void (*put)(struct klist_node *) = i->i_klist->put;
264 265
265 spin_lock(&i->i_klist->k_lock); 266 spin_lock(&i->i_klist->k_lock);
266 if (i->i_cur) { 267 if (lnode) {
267 next = i->i_cur->n_node.next; 268 next = lnode->n_node.next;
268 klist_dec_and_del(i->i_cur); 269 if (!klist_dec_and_del(lnode))
270 put = NULL;
269 } else 271 } else
270 next = i->i_head->next; 272 next = i->i_head->next;
271 273
@@ -275,6 +277,8 @@ struct klist_node * klist_next(struct klist_iter * i)
275 } 277 }
276 i->i_cur = knode; 278 i->i_cur = knode;
277 spin_unlock(&i->i_klist->k_lock); 279 spin_unlock(&i->i_klist->k_lock);
280 if (put && lnode)
281 put(lnode);
278 return knode; 282 return knode;
279} 283}
280 284
diff --git a/lib/kobject.c b/lib/kobject.c
index 8e7c71993487..1699eb9161f3 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -407,6 +407,7 @@ static struct kobj_type dir_ktype = {
407struct kobject *kobject_add_dir(struct kobject *parent, const char *name) 407struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
408{ 408{
409 struct kobject *k; 409 struct kobject *k;
410 int ret;
410 411
411 if (!parent) 412 if (!parent)
412 return NULL; 413 return NULL;
@@ -418,7 +419,13 @@ struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
418 k->parent = parent; 419 k->parent = parent;
419 k->ktype = &dir_ktype; 420 k->ktype = &dir_ktype;
420 kobject_set_name(k, name); 421 kobject_set_name(k, name);
421 kobject_register(k); 422 ret = kobject_register(k);
423 if (ret < 0) {
424 printk(KERN_WARNING "kobject_add_dir: "
425 "kobject_register error: %d\n", ret);
426 kobject_del(k);
427 return NULL;
428 }
422 429
423 return k; 430 return k;
424} 431}