Re: [PATCH] nubus: Unconditionally register bus type

From: Finn Thain
Date: Tue May 08 2018 - 03:59:55 EST


On Tue, 8 May 2018, Geert Uytterhoeven wrote:

> > This example is the sort of flag removal that I had in mind --
> >
> > diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> > index ba912558a510..4ee22fb3db92 100644
> > --- a/drivers/base/driver.c
> > +++ b/drivers/base/driver.c
> > @@ -148,7 +148,8 @@ int driver_register(struct device_driver *drv)
> > int ret;
> > struct device_driver *other;
> >
> > - BUG_ON(!drv->bus->p);
> > + if (!drv->bus->p)
> > + return -ENODEV;
>
> If this is meant to handle the case where the device driver is registered
> before the bus is registered, while the latter can still happen later,
> then you want to return -EPROBE_DEFER.
>

Returning -EAGAIN might be appropriate if driver_register() could
reasonably expect the bus to come into existence.

However, a separation of concerns would seem to imply that the driver core
has no way of knowing whether that might happen.

Anyway, this discussion is academic. The patch was only meant to
illustrate a way to remove code instead of adding it, while achieving the
same goal.

I'm not proposing this patch. I don't claim to understand all of the
considerations that apply here. I'm certain there are situations where
BUG_ON is appropriate. This may be one of those situations.

--

> Gr{oetje,eeting}s,
>
> Geert
>
>