Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Greg KH
On Fri, Nov 30, 2007 at 06:22:37PM -0500, Alan Stern wrote: > On Fri, 30 Nov 2007, Greg KH wrote: > > And you > > can't know that, so you have to call kobject_put() in order to be safe > > and clean up everything. > > > > Now why did we not do the final kobject_put() in kobject_del() as well? > >

Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Alan Stern
On Fri, 30 Nov 2007, Greg KH wrote: > > However if kobject_add() is never called, or if it is called and it > > fails, then it's okay to use kfree(). It's not clear whether this > > distinction will matter in practice. It's probably best to document > > this using your stronger description. >

Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Greg KH
On Fri, Nov 30, 2007 at 05:10:33PM -0500, Alan Stern wrote: > On Fri, 30 Nov 2007, Greg KH wrote: > > > Ok, how about this: > > void kobject_init(struct kobject *kobj, struct ktype *ktype); > > > > and then: > > int kobject_add(struct kobject *kobj, struct kobject *parent, const > > char

Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Greg KH
On Fri, Nov 30, 2007 at 05:10:33PM -0500, Alan Stern wrote: > On Fri, 30 Nov 2007, Greg KH wrote: > > > Ok, how about this: > > void kobject_init(struct kobject *kobj, struct ktype *ktype); > > > > and then: > > int kobject_add(struct kobject *kobj, struct kobject *parent, const > > char

Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Alan Stern
On Fri, 30 Nov 2007, Greg KH wrote: > Ok, how about this: > void kobject_init(struct kobject *kobj, struct ktype *ktype); > > and then: > int kobject_add(struct kobject *kobj, struct kobject *parent, const > char *fmt, ...); > > After we call kobject_init() we HAVE to call kobject_p

Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Greg KH
On Fri, Nov 30, 2007 at 04:19:53PM -0500, Alan Stern wrote: > On Fri, 30 Nov 2007, Greg KH wrote: > > > > My suggestion: Have kobject_init_ng() accept a ktype pointer but not a > > > parent or name. Instead, make kobject_add_ng() take the parent and > > > name (possibly a kset also). Then when

Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Alan Stern
On Fri, 30 Nov 2007, Greg KH wrote: > > My suggestion: Have kobject_init_ng() accept a ktype pointer but not a > > parent or name. Instead, make kobject_add_ng() take the parent and > > name (possibly a kset also). Then when kobject_init_and_add() > > encounters an error, it shouldn't do a _p

Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Greg KH
On Fri, Nov 30, 2007 at 01:04:20PM -0800, Greg KH wrote: > > My suggestion: Have kobject_init_ng() accept a ktype pointer but not a > > parent or name. Instead, make kobject_add_ng() take the parent and > > name (possibly a kset also). Then when kobject_init_and_add() > > encounters an error,

Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Greg KH
On Fri, Nov 30, 2007 at 03:25:52PM -0500, Alan Stern wrote: > On Fri, 30 Nov 2007, Greg KH wrote: > > > +/** > > + * kobject_init_and_add - initialize a kobject structure and add it to the > > kobject hierarchy > > + * @kobj: pointer to the kobject to initialize > > + * @ktype: pointer to the kty

Re: [RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Alan Stern
On Fri, 30 Nov 2007, Greg KH wrote: > +/** > + * kobject_init_and_add - initialize a kobject structure and add it to the > kobject hierarchy > + * @kobj: pointer to the kobject to initialize > + * @ktype: pointer to the ktype for this kobject. > + * @parent: pointer to the parent of this kobject.

[RFC] kobject: add kobject_init_ng and kobject_init_and_add functions

2007-11-30 Thread Greg KH
This is what the kobject_init function is going to become. Add it to the kernel and then we can convert over the current kobject_init() users before renaming it. Also add a kobject_init_and_add function which bundles up what a lot of the current callers want to do all at once, and it properly han