Re: [char-misc-next 02/11 V2] mei: bus: Implement driver registration

From: Greg KH
Date: Sun Feb 10 2013 - 11:36:22 EST


On Sun, Feb 10, 2013 at 04:32:18AM +0100, Samuel Ortiz wrote:
> Hi Greg,
>
> On Fri, Feb 08, 2013 at 03:55:24PM -0800, Greg KH wrote:
> > On Fri, Feb 08, 2013 at 02:28:15PM +0200, Tomas Winkler wrote:
> > > From: Samuel Ortiz <sameo@xxxxxxxxxxxxxxx>
> > >
> > > Signed-off-by: Samuel Ortiz <sameo@xxxxxxxxxxxxxxx>
> > > Signed-off-by: Tomas Winkler <tomas.winkler@xxxxxxxxx>
> > > Acked-by: Arnd Bergmann <arnd@xxxxxxxx>
> > > ---
> > > drivers/misc/mei/bus.c | 29 +++++++++++++++++++++++++++++
> > > include/linux/mei_bus.h | 3 +++
> > > 2 files changed, 32 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
> > > index bb96423c..0a5e624 100644
> > > --- a/drivers/misc/mei/bus.c
> > > +++ b/drivers/misc/mei/bus.c
> > > @@ -153,3 +153,32 @@ void mei_remove_device(struct mei_bus_client *client)
> > > device_unregister(&client->dev);
> > > }
> > > EXPORT_SYMBOL(mei_remove_device);
> > > +
> > > +int mei_driver_register(struct mei_bus_driver *driver)
> > > +{
> > > + int err;
> > > +
> > > + /* Can't register until after driver model init */
> > > + if (unlikely(WARN_ON(!mei_bus_type.p)))
> > > + return -EAGAIN;
> >
> > No, you really don't know what 'p' is, so don't assume you do. You have
> > fields you can test to see if your driver model is up and registered,
> > use them instead.
> Unless I'm missing something, I would actually need to track if the bus type
> is registered or not from bus.c. I can't find any field from bus_type that
> tells me for sure if my bus is registered or not, except for p.
> I actually think I don't need that check anyway. IIRC, this is something I
> took from i2c-core.c but in the ME case it's most likely not needed.

It's your bus, if you need to check this, then have your own flag, don't
poke in the driver core internals. As you point out, I don't think you
need to check this at all.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/