Re: [RFC] New kobject/kset/ktype documentation and example code

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Greg KH <greg@...>
Cc: Cornelia Huck <cornelia.huck@...>, <linux-kernel@...>, Alan Stern <stern@...>, Jonathan Corbet <corbet@...>, Randy Dunlap <randy.dunlap@...>
Date: Thursday, November 29, 2007 - 3:50 am

On Wed, 2007-11-28 at 22:08 -0800, Greg KH wrote:

Accept that the kobject API is that low-level, that we can't have a
proper convenience API - it just does the wrong thing.
Do the same for all other in-kernel users what we did 2.5 years ago for
the driver core, and no longer use the kobject/kset_register()
functions, and let the caller send the events manually when the object
is ready, or removed.

We have ~20 callers of kobject_(un)register(), convert them to
kobject_init() + kobject_add() + kobject_uevent(), and just delete the
broken kobject_(un)register() functions from the kobject code.

Rename the new kobject/kset_create_and_register() to _create_and_add()
and also require the uevent to be sent manually when the caller is ready
with the object.

That way we get rid of a broken API which causes far more problems than
it solves. And we will no longer need to carry this in the example code:
/*
 * Note, these files will be created _after_ the kobject above
 * created.  This can cause userspace to be looking around in sysfs
 * for these files before they are really created.  If you are
 * worried about something like this, perhaps you really need to
 * create your own kset and have a default attribute group for your
 * kobject.
 */

We just get one single API, and we document that the caller needs to
send an event when it has finished populating the object, or deletes the
object.
If we are worrying about users who might forget to send events - I
really prefer missing uevents, which we can simply add, over ones with
the broken timing the current API causes, and failing userspace where
nobody understands what's going wrong at event time. :)

Thanks,
Kay

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
kobject_init rewrite, Greg KH, (Thu Nov 29, 5:53 pm)
Re: kobject_init rewrite, Alan Stern, (Thu Nov 29, 6:16 pm)
Re: kobject_init rewrite, Greg KH, (Thu Nov 29, 6:24 pm)
Re: kobject_init rewrite, Greg KH, (Thu Nov 29, 5:54 pm)
Re: kobject_init rewrite, Cornelia Huck, (Fri Nov 30, 5:31 am)
Re: [RFC] New kobject/kset/ktype documentation and example c..., Kay Sievers, (Thu Nov 29, 3:50 am)
[RFC] Sample kset/ktype/kobject implementation, Greg KH, (Tue Nov 27, 7:04 pm)
Re: [RFC] Sample kset/ktype/kobject implementation, Cornelia Huck, (Wed Nov 28, 12:35 pm)
Re: [RFC] Sample kset/ktype/kobject implementation, Cornelia Huck, (Thu Nov 29, 5:39 am)
Re: [RFC] Sample kset/ktype/kobject implementation, Alan Stern, (Thu Nov 29, 6:11 pm)
Re: [RFC] Sample kset/ktype/kobject implementation, Dave Young, (Fri Nov 30, 1:07 am)
Re: [RFC] Sample kset/ktype/kobject implementation, Alan Stern, (Fri Nov 30, 10:51 am)
Re: [RFC] Sample kset/ktype/kobject implementation, Dave Young, (Fri Nov 30, 1:57 am)
[RFC] sample kobject implementation, Greg KH, (Tue Nov 27, 7:03 pm)