From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Driver Core patches for 2.6.9-rc1
Date: Wed, 25 Aug 2004 15:36:28 -0700 [thread overview]
Message-ID: <10934733881261@kroah.com> (raw)
In-Reply-To: <1093473388797@kroah.com>
ChangeSet 1.1803.64.8, 2004/08/25 12:30:41-07:00, greg@kroah.com
kobject: convert struct kobject use kref.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
include/linux/kobject.h | 3 ++-
lib/Makefile | 5 +----
lib/kobject.c | 19 ++++++++++---------
3 files changed, 13 insertions(+), 14 deletions(-)
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
--- a/include/linux/kobject.h 2004-08-25 14:54:37 -07:00
+++ b/include/linux/kobject.h 2004-08-25 14:54:37 -07:00
@@ -19,6 +19,7 @@
#include <linux/list.h>
#include <linux/sysfs.h>
#include <linux/rwsem.h>
+#include <linux/kref.h>
#include <asm/atomic.h>
#define KOBJ_NAME_LEN 20
@@ -26,7 +27,7 @@
struct kobject {
char * k_name;
char name[KOBJ_NAME_LEN];
- atomic_t refcount;
+ struct kref kref;
struct list_head entry;
struct kobject * parent;
struct kset * kset;
diff -Nru a/lib/Makefile b/lib/Makefile
--- a/lib/Makefile 2004-08-25 14:54:37 -07:00
+++ b/lib/Makefile 2004-08-25 14:54:37 -07:00
@@ -5,11 +5,8 @@
lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
- kobject.o idr.o div64.o parser.o int_sqrt.o \
+ kobject.o kref.o idr.o div64.o parser.o int_sqrt.o \
bitmap.o extable.o
-
-# hack for now till some static code uses krefs, then it can move up above...
-obj-y += kref.o
lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
diff -Nru a/lib/kobject.c b/lib/kobject.c
--- a/lib/kobject.c 2004-08-25 14:54:37 -07:00
+++ b/lib/kobject.c 2004-08-25 14:54:37 -07:00
@@ -243,10 +243,9 @@
* kobject_init - initialize object.
* @kobj: object in question.
*/
-
void kobject_init(struct kobject * kobj)
{
- atomic_set(&kobj->refcount,1);
+ kref_init(&kobj->kref);
INIT_LIST_HEAD(&kobj->entry);
kobj->kset = kset_get(kobj->kset);
}
@@ -447,10 +446,8 @@
struct kobject * kobject_get(struct kobject * kobj)
{
- if (kobj) {
- WARN_ON(!atomic_read(&kobj->refcount));
- atomic_inc(&kobj->refcount);
- }
+ if (kobj)
+ kref_get(&kobj->kref);
return kobj;
}
@@ -477,17 +474,21 @@
kobject_put(parent);
}
+static void kobject_release(struct kref *kref)
+{
+ kobject_cleanup(container_of(kref, struct kobject, kref));
+}
+
/**
* kobject_put - decrement refcount for object.
* @kobj: object.
*
* Decrement the refcount, and if 0, call kobject_cleanup().
*/
-
void kobject_put(struct kobject * kobj)
{
- if (atomic_dec_and_test(&kobj->refcount))
- kobject_cleanup(kobj);
+ if (kobj)
+ kref_put(&kobj->kref, kobject_release);
}
next prev parent reply other threads:[~2004-08-25 22:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-25 22:35 [BK PATCH] Driver Core patches for 2.6.9-rc1 Greg KH
2004-08-25 22:36 ` [PATCH] " Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH [this message]
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-25 22:36 ` Greg KH
2004-08-26 2:04 ` Benjamin Herrenschmidt
2004-08-26 4:10 ` Greg KH
2004-08-26 12:26 ` Jean Delvare
2004-08-26 23:33 ` Benjamin Herrenschmidt
2004-08-27 10:16 ` Jean Delvare
-- strict thread matches above, loose matches on Subject: below --
2004-08-26 18:15 Margit Schubert-While
[not found] <200408261957.58105.margitsw@t-online.de>
[not found] ` <5.1.0.14.2.20040908220127.02a9daa8@pop.t-online.de>
2004-09-08 20:21 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10934733881261@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox