Re: [RFC] sample kset/ktype/kobject implementation code

2008-01-03 Thread Cornelia Huck
On Wed, 19 Dec 2007 16:31:35 -0800, Greg KH <[EMAIL PROTECTED]> wrote: > /* >* Initialize and add the kobject to the kernel. All the default files >* will be created here. As we have already specified a kset for this >* kobject, we don't have to set a parent for

Re: [RFC] sample kset/ktype/kobject implementation code

2008-01-03 Thread Cornelia Huck
On Wed, 19 Dec 2007 16:31:35 -0800, Greg KH [EMAIL PROTECTED] wrote: /* * Initialize and add the kobject to the kernel. All the default files * will be created here. As we have already specified a kset for this * kobject, we don't have to set a parent for the

[RFC] sample kset/ktype/kobject implementation code

2007-12-19 Thread Greg KH
/* * Sample kset and ktype implementation * * Copyright (C) 2004-2007 Greg Kroah-Hartman <[EMAIL PROTECTED]> * Copyright (C) 2007 Novell Inc. * * Released under the GPL version 2 only. * */ #include #include #include #include #include /* * This module shows how to create a kset in

[RFC] sample kset/ktype/kobject implementation code

2007-12-19 Thread Greg KH
/* * Sample kset and ktype implementation * * Copyright (C) 2004-2007 Greg Kroah-Hartman [EMAIL PROTECTED] * Copyright (C) 2007 Novell Inc. * * Released under the GPL version 2 only. * */ #include linux/kobject.h #include linux/string.h #include linux/sysfs.h #include linux/module.h

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-30 Thread Alan Stern
On Fri, 30 Nov 2007, Dave Young wrote: > > The rule is simple enough. After calling kobject_register() you should > > always use kobject_put() -- even if kobject_register() failed. > > > > In fact, after calling kobject_init() you should use kobject_put(). > > The first rule follows from this

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-30 Thread Alan Stern
On Fri, 30 Nov 2007, Dave Young wrote: The rule is simple enough. After calling kobject_register() you should always use kobject_put() -- even if kobject_register() failed. In fact, after calling kobject_init() you should use kobject_put(). The first rule follows from this one, since

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Greg KH
On Thu, Nov 29, 2007 at 05:11:35PM -0500, Alan Stern wrote: > On Thu, 29 Nov 2007, Greg KH wrote: > > > > > > kobject_put(foo) is needed since it gets you through kobject_cleanup() > > > > > where the name can be freed. > > > > > > > > No, kobject_register() should have handled that for us,

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Dave Young
On Fri, Nov 30, 2007 at 01:07:37PM +0800, Dave Young wrote: > On Nov 30, 2007 6:11 AM, Alan Stern <[EMAIL PROTECTED]> wrote: > > On Thu, 29 Nov 2007, Greg KH wrote: > > > > > > > > kobject_put(foo) is needed since it gets you through > > > > > > kobject_cleanup() > > > > > > where the name can be

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Dave Young
On Nov 30, 2007 6:11 AM, Alan Stern <[EMAIL PROTECTED]> wrote: > On Thu, 29 Nov 2007, Greg KH wrote: > > > > > > kobject_put(foo) is needed since it gets you through kobject_cleanup() > > > > > where the name can be freed. > > > > > > > > No, kobject_register() should have handled that for us,

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Greg KH wrote: > > > > kobject_put(foo) is needed since it gets you through kobject_cleanup() > > > > where the name can be freed. > > > > > > No, kobject_register() should have handled that for us, right? > > > > kobject_register() doesn't do a kobject_put() if

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Greg KH
On Thu, Nov 29, 2007 at 10:39:07AM +0100, Cornelia Huck wrote: > On Wed, 28 Nov 2007 22:11:39 -0800, > Greg KH <[EMAIL PROTECTED]> wrote: > > > > > foo->kobj.kset = example_kset; > > > > foo->kobj.ktype = _ktype; > > > > > > > > /* > > > > * Register the kobject

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Cornelia Huck
On Wed, 28 Nov 2007 22:11:39 -0800, Greg KH <[EMAIL PROTECTED]> wrote: > > > foo->kobj.kset = example_kset; > > > foo->kobj.ktype = _ktype; > > > > > > /* > > >* Register the kobject with the kernel, all the default files will > > >* be created here and the uevent will be sent out.

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Cornelia Huck
On Wed, 28 Nov 2007 22:11:39 -0800, Greg KH [EMAIL PROTECTED] wrote: foo-kobj.kset = example_kset; foo-kobj.ktype = foo_ktype; /* * Register the kobject with the kernel, all the default files will * be created here and the uevent will be sent out. If we were to

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Greg KH
On Thu, Nov 29, 2007 at 10:39:07AM +0100, Cornelia Huck wrote: On Wed, 28 Nov 2007 22:11:39 -0800, Greg KH [EMAIL PROTECTED] wrote: foo-kobj.kset = example_kset; foo-kobj.ktype = foo_ktype; /* * Register the kobject with the kernel, all the

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Greg KH wrote: kobject_put(foo) is needed since it gets you through kobject_cleanup() where the name can be freed. No, kobject_register() should have handled that for us, right? kobject_register() doesn't do a kobject_put() if kobject_add() failed.

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Dave Young
On Nov 30, 2007 6:11 AM, Alan Stern [EMAIL PROTECTED] wrote: On Thu, 29 Nov 2007, Greg KH wrote: kobject_put(foo) is needed since it gets you through kobject_cleanup() where the name can be freed. No, kobject_register() should have handled that for us, right?

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Dave Young
On Fri, Nov 30, 2007 at 01:07:37PM +0800, Dave Young wrote: On Nov 30, 2007 6:11 AM, Alan Stern [EMAIL PROTECTED] wrote: On Thu, 29 Nov 2007, Greg KH wrote: kobject_put(foo) is needed since it gets you through kobject_cleanup() where the name can be freed. No,

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-29 Thread Greg KH
On Thu, Nov 29, 2007 at 05:11:35PM -0500, Alan Stern wrote: On Thu, 29 Nov 2007, Greg KH wrote: kobject_put(foo) is needed since it gets you through kobject_cleanup() where the name can be freed. No, kobject_register() should have handled that for us, right?

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-28 Thread Greg KH
On Wed, Nov 28, 2007 at 05:35:32PM +0100, Cornelia Huck wrote: > On Tue, 27 Nov 2007 15:04:06 -0800, > Greg KH <[EMAIL PROTECTED]> wrote: > > > static struct foo_obj *create_foo_obj(const char *name) > > { > > struct foo_obj *foo; > > int retval; > > > > /* allocate the memory for

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-28 Thread Cornelia Huck
On Tue, 27 Nov 2007 15:04:06 -0800, Greg KH <[EMAIL PROTECTED]> wrote: > static struct foo_obj *create_foo_obj(const char *name) > { > struct foo_obj *foo; > int retval; > > /* allocate the memory for the whole object */ > foo = kzalloc(sizeof(*foo), GFP_KERNEL); >

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-28 Thread Cornelia Huck
On Tue, 27 Nov 2007 15:04:06 -0800, Greg KH [EMAIL PROTECTED] wrote: static struct foo_obj *create_foo_obj(const char *name) { struct foo_obj *foo; int retval; /* allocate the memory for the whole object */ foo = kzalloc(sizeof(*foo), GFP_KERNEL); if (!foo)

Re: [RFC] Sample kset/ktype/kobject implementation

2007-11-28 Thread Greg KH
On Wed, Nov 28, 2007 at 05:35:32PM +0100, Cornelia Huck wrote: On Tue, 27 Nov 2007 15:04:06 -0800, Greg KH [EMAIL PROTECTED] wrote: static struct foo_obj *create_foo_obj(const char *name) { struct foo_obj *foo; int retval; /* allocate the memory for the whole object */

[RFC] Sample kset/ktype/kobject implementation

2007-11-27 Thread Greg KH
/* * Sample kset and ktype implementation * * Copyright (C) 2004-2007 Greg Kroah-Hartman <[EMAIL PROTECTED]> * Copyright (C) 2007 Novell Inc. * * Released under the GPL version 2 only. * */ #include #include #include #include #include /* * This module shows how to create a kset in

[RFC] Sample kset/ktype/kobject implementation

2007-11-27 Thread Greg KH
/* * Sample kset and ktype implementation * * Copyright (C) 2004-2007 Greg Kroah-Hartman [EMAIL PROTECTED] * Copyright (C) 2007 Novell Inc. * * Released under the GPL version 2 only. * */ #include linux/kobject.h #include linux/string.h #include linux/sysfs.h #include linux/module.h