Re: [PATCH 34/54] Driver Core: add kobj_attribute handling

Greg KH
2007-11-05T18:47:24Z

On Mon, Nov 05, 2007 at 07:39:31PM +0100, Kay Sievers wrote:
> On Mon, 2007-11-05 at 19:17 +0100, Cornelia Huck wrote:
> > On Mon, 05 Nov 2007 19:07:50 +0100,
> > Kay Sievers <kay.sievers@vrfy.org> wrote:
> >
> > > On Mon, 2007-11-05 at 18:43 +0100, Cornelia Huck wrote:
> > > > On Mon, 05 Nov 2007 18:25:40 +0100,
> > > > Kay Sievers <kay.sievers@vrfy.org> wrote:
> > > >
> > > > > > > That should usually be done by default attributes assigned to the ktype.
> > > > > > > Do you have a good use case, where people need to create such attributes
> > > > > > > individually instead?
> > > > > >
> > > > > > The s390 code that was converted to use kobj_attributes :)
> > > > > >
> > > > > > These look very useful, I'll go add them to the series unless Kay really
> > > > > > objects.
> > > > >
> > > > > I just want to hear a good reason to create attributes individually. :)
> > > > > Especially in conjunction with kobject_register(), these attributes are
> > > > > not available at uevent time, which is really really bad.
> > > > >
> > > > > Default attributes just work fine, and have the proper error handling
> > > > > built-in. Offering special functions for it, may just encourage people
> > > > > to continue this "broken" way of creating attributes.
> > > >
> > > > But where should I specify those default attributes?
> > > > kset_create_and_register() sets the ktype to kset_ktype...
> > >
> > > Do you need to create attributes at a kset itself, not the kobjects that
> > > belong to the kset?
> >
> > Yes, see arch/s390/kernel/ipl.c
>
> Where are the objects that join this kset? A kset is a "collection of
> objects of a similar type", If there are no objects, you don't need a
> kset at all, I guess, but just a plain directory. :)
>
> Anyway, seems we need an easy way to pass default attributes to ksets
> and plain directories. If userspace should set some values here when a
> subsystems creates the its sysfs representation, we must make sure, that
> the attributes exist at the time the event is sent, otherwise we will
> run into all sorts of timing problems.

Kay is right, it should be simple to add the kobject attributes to the
kobject itself when it is registered to this kset, right?

> > (and I guess anything that uses
> > subsys_create_file() before).
>
> Well, some users embedded ksets(subsystem) into objects, because it they
> confused kobjects and ksets. So there may be a only very few valid users
> left. :)

Hm, I don't think that anyone still does this anymore, as I think I
fixed up all of these horrible use cases :)

thanks,

greg k-h