Re: [PATCH] gpiolib: Allow user-selection

David Brownell
2008-07-12T05:32:53Z

On Thursday 03 July 2008, Greg KH wrote:
> > The scenario is that gpios sometimes get initialized very early,
> > as part of board setup before kmalloc or irqs work, so when they
> > get registered sometimes there's work left over for later.  All
> > that's needed is a predicate to test whether that class can be
> > used as a parameter to stuff like device_create_drvdata() and
> > sysfs_create_group().
>
> If you want to see if a class has any devices in it, just do a search
> for any device instead of poking into that field.  Or I can wrap that up
> in the driver core if needed.

That would require taking driver model mutexes before
tasking is working and driver_init() is called. GPIOs
are regularly used *really* early in board setup ... even
before IRQs are working.

Are driver model searches really expected to work then??

Seems simpler to me to just check "is pointer NULL",
when we know that the pointer is initialized by the
class initialization, and (because the relevant struct
is zero-initialized) null beforehand. That works more
or less any point during kernel initialization ... not
just after the first task is running. Plus it's not
as expensive. :)

- Dave