diff options
Diffstat (limited to 'lib/kobject.c')
| -rw-r--r-- | lib/kobject.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index ba1cdd69f775..21f876504c5e 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -17,10 +17,6 @@ #include <linux/module.h> #include <linux/stat.h> -/* This lock can be removed entirely when the sysfs_init() code is cleaned up - * to not try to reference itself before it is initialized. */ -static spinlock_t kobj_lock = SPIN_LOCK_UNLOCKED; - /** * populate_dir - populate directory with attributes. * @kobj: object we're working on. @@ -350,14 +346,11 @@ void kobject_unregister(struct kobject * kobj) struct kobject * kobject_get(struct kobject * kobj) { struct kobject * ret = kobj; - unsigned long flags; - spin_lock_irqsave(&kobj_lock, flags); - if (kobj && atomic_read(&kobj->refcount) > 0) + if (kobj) atomic_inc(&kobj->refcount); else ret = NULL; - spin_unlock_irqrestore(&kobj_lock, flags); return ret; } @@ -387,15 +380,8 @@ void kobject_cleanup(struct kobject * kobj) void kobject_put(struct kobject * kobj) { - unsigned long flags; - - local_irq_save(flags); - if (atomic_dec_and_lock(&kobj->refcount, &kobj_lock)) { - spin_unlock_irqrestore(&kobj_lock, flags); + if (atomic_dec_and_test(&kobj->refcount)) kobject_cleanup(kobj); - } else { - local_irq_restore(flags); - } } |
