lkml.org 
[lkml]   [2018]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] nubus: Unconditionally register bus type
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
>
>

\
 
 \ /
  Last update: 2018-05-08 10:00    [W:0.070 / U:1.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site