aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/extable.c1
-rw-r--r--lib/kobject.c60
-rw-r--r--lib/kobject_uevent.c2
-rw-r--r--lib/kref.c7
-rw-r--r--lib/reed_solomon/reed_solomon.c11
-rw-r--r--lib/string.c1
6 files changed, 66 insertions, 16 deletions
diff --git a/lib/extable.c b/lib/extable.c
index 18df57c029df..01c08b5836f5 100644
--- a/lib/extable.c
+++ b/lib/extable.c
@@ -1,5 +1,4 @@
1/* 1/*
2 * lib/extable.c
3 * Derived from arch/ppc/mm/extable.c and arch/i386/mm/extable.c. 2 * Derived from arch/ppc/mm/extable.c and arch/i386/mm/extable.c.
4 * 3 *
5 * Copyright (C) 2004 Paul Mackerras, IBM Corp. 4 * Copyright (C) 2004 Paul Mackerras, IBM Corp.
diff --git a/lib/kobject.c b/lib/kobject.c
index efe67fa96a71..25204a41a9b0 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -194,6 +194,17 @@ int kobject_add(struct kobject * kobj)
194 unlink(kobj); 194 unlink(kobj);
195 if (parent) 195 if (parent)
196 kobject_put(parent); 196 kobject_put(parent);
197
198 /* be noisy on error issues */
199 if (error == -EEXIST)
200 printk("kobject_add failed for %s with -EEXIST, "
201 "don't try to register things with the "
202 "same name in the same directory.\n",
203 kobject_name(kobj));
204 else
205 printk("kobject_add failed for %s (%d)\n",
206 kobject_name(kobj), error);
207 dump_stack();
197 } 208 }
198 209
199 return error; 210 return error;
@@ -207,18 +218,13 @@ int kobject_add(struct kobject * kobj)
207 218
208int kobject_register(struct kobject * kobj) 219int kobject_register(struct kobject * kobj)
209{ 220{
210 int error = 0; 221 int error = -EINVAL;
211 if (kobj) { 222 if (kobj) {
212 kobject_init(kobj); 223 kobject_init(kobj);
213 error = kobject_add(kobj); 224 error = kobject_add(kobj);
214 if (error) { 225 if (!error)
215 printk("kobject_register failed for %s (%d)\n",
216 kobject_name(kobj),error);
217 dump_stack();
218 } else
219 kobject_uevent(kobj, KOBJ_ADD); 226 kobject_uevent(kobj, KOBJ_ADD);
220 } else 227 }
221 error = -EINVAL;
222 return error; 228 return error;
223} 229}
224 230
@@ -379,6 +385,44 @@ void kobject_put(struct kobject * kobj)
379} 385}
380 386
381 387
388static void dir_release(struct kobject *kobj)
389{
390 kfree(kobj);
391}
392
393static struct kobj_type dir_ktype = {
394 .release = dir_release,
395 .sysfs_ops = NULL,
396 .default_attrs = NULL,
397};
398
399/**
400 * kobject_add_dir - add sub directory of object.
401 * @parent: object in which a directory is created.
402 * @name: directory name.
403 *
404 * Add a plain directory object as child of given object.
405 */
406struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
407{
408 struct kobject *k;
409
410 if (!parent)
411 return NULL;
412
413 k = kzalloc(sizeof(*k), GFP_KERNEL);
414 if (!k)
415 return NULL;
416
417 k->parent = parent;
418 k->ktype = &dir_ktype;
419 kobject_set_name(k, name);
420 kobject_register(k);
421
422 return k;
423}
424EXPORT_SYMBOL_GPL(kobject_add_dir);
425
382/** 426/**
383 * kset_init - initialize a kset for use 427 * kset_init - initialize a kset for use
384 * @k: kset 428 * @k: kset
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 086a0c6e888e..982226daf939 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -26,6 +26,8 @@
26#define NUM_ENVP 32 /* number of env pointers */ 26#define NUM_ENVP 32 /* number of env pointers */
27 27
28#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 28#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
29u64 uevent_seqnum;
30char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
29static DEFINE_SPINLOCK(sequence_lock); 31static DEFINE_SPINLOCK(sequence_lock);
30static struct sock *uevent_sock; 32static struct sock *uevent_sock;
31 33
diff --git a/lib/kref.c b/lib/kref.c
index 0d07cc31c818..4a467faf1367 100644
--- a/lib/kref.c
+++ b/lib/kref.c
@@ -52,7 +52,12 @@ int kref_put(struct kref *kref, void (*release)(struct kref *kref))
52 WARN_ON(release == NULL); 52 WARN_ON(release == NULL);
53 WARN_ON(release == (void (*)(struct kref *))kfree); 53 WARN_ON(release == (void (*)(struct kref *))kfree);
54 54
55 if (atomic_dec_and_test(&kref->refcount)) { 55 /*
56 * if current count is one, we are the last user and can release object
57 * right now, avoiding an atomic operation on 'refcount'
58 */
59 if ((atomic_read(&kref->refcount) == 1) ||
60 (atomic_dec_and_test(&kref->refcount))) {
56 release(kref); 61 release(kref);
57 return 1; 62 return 1;
58 } 63 }
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c
index f5fef948a415..f8ac9fa95de1 100644
--- a/lib/reed_solomon/reed_solomon.c
+++ b/lib/reed_solomon/reed_solomon.c
@@ -44,12 +44,13 @@
44#include <linux/module.h> 44#include <linux/module.h>
45#include <linux/rslib.h> 45#include <linux/rslib.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/mutex.h>
47#include <asm/semaphore.h> 48#include <asm/semaphore.h>
48 49
49/* This list holds all currently allocated rs control structures */ 50/* This list holds all currently allocated rs control structures */
50static LIST_HEAD (rslist); 51static LIST_HEAD (rslist);
51/* Protection for the list */ 52/* Protection for the list */
52static DECLARE_MUTEX(rslistlock); 53static DEFINE_MUTEX(rslistlock);
53 54
54/** 55/**
55 * rs_init - Initialize a Reed-Solomon codec 56 * rs_init - Initialize a Reed-Solomon codec
@@ -161,7 +162,7 @@ errrs:
161 */ 162 */
162void free_rs(struct rs_control *rs) 163void free_rs(struct rs_control *rs)
163{ 164{
164 down(&rslistlock); 165 mutex_lock(&rslistlock);
165 rs->users--; 166 rs->users--;
166 if(!rs->users) { 167 if(!rs->users) {
167 list_del(&rs->list); 168 list_del(&rs->list);
@@ -170,7 +171,7 @@ void free_rs(struct rs_control *rs)
170 kfree(rs->genpoly); 171 kfree(rs->genpoly);
171 kfree(rs); 172 kfree(rs);
172 } 173 }
173 up(&rslistlock); 174 mutex_unlock(&rslistlock);
174} 175}
175 176
176/** 177/**
@@ -201,7 +202,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
201 if (nroots < 0 || nroots >= (1<<symsize)) 202 if (nroots < 0 || nroots >= (1<<symsize))
202 return NULL; 203 return NULL;
203 204
204 down(&rslistlock); 205 mutex_lock(&rslistlock);
205 206
206 /* Walk through the list and look for a matching entry */ 207 /* Walk through the list and look for a matching entry */
207 list_for_each(tmp, &rslist) { 208 list_for_each(tmp, &rslist) {
@@ -228,7 +229,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
228 list_add(&rs->list, &rslist); 229 list_add(&rs->list, &rslist);
229 } 230 }
230out: 231out:
231 up(&rslistlock); 232 mutex_unlock(&rslistlock);
232 return rs; 233 return rs;
233} 234}
234 235
diff --git a/lib/string.c b/lib/string.c
index 037a48acedbb..b3c28a3f6332 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -403,7 +403,6 @@ char *strpbrk(const char *cs, const char *ct)
403 } 403 }
404 return NULL; 404 return NULL;
405} 405}
406EXPORT_SYMBOL(strpbrk);
407#endif 406#endif
408 407
409#ifndef __HAVE_ARCH_STRSEP 408#ifndef __HAVE_ARCH_STRSEP