lkml.org 
[lkml]   [2015]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist
On Thu, May 28, 2015 at 11:09:38AM +0530, Sudip Mukherjee wrote:
> On Wed, May 27, 2015 at 08:21:16AM -0700, Greg KH wrote:
> > On Wed, May 27, 2015 at 11:16:34AM -0400, Alan Stern wrote:
> > > On Wed, 27 May 2015, Heikki Krogerus wrote:
> >
> > Maybe we need to test for this in the driver core, not allowing drivers
> > for busses that are not registered, that might solve the main problem
> > here. I'll try to look at it tonight.
> may i suggest something like this ?
> buildtest with allmodconfig and allyesconfig on x86_64.
> built and booted on x86.
>
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 5005924..95cefa0 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -943,6 +943,7 @@ int bus_register(struct bus_type *bus)
> if (retval)
> goto bus_groups_fail;
>
> + bus->registered = true;
> pr_debug("bus: '%s': registered\n", bus->name);
> return 0;
>
> diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> index 4eabfe2..1acae5b 100644
> --- a/drivers/base/driver.c
> +++ b/drivers/base/driver.c
> @@ -150,6 +150,11 @@ int driver_register(struct device_driver *drv)
> int ret;
> struct device_driver *other;
>
> + if (!drv->bus->registered) {
> + pr_err("Driver %s registration failed. bus not yet registered\n",
> + drv->name);
> + return -ENODEV;
> + }
> BUG_ON(!drv->bus->p);
>
> if ((drv->bus->probe && drv->probe) ||
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 00ac57c..8fe4745 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -126,6 +126,7 @@ struct bus_type {
> const struct dev_pm_ops *pm;
>
> const struct iommu_ops *iommu_ops;
> + bool registered; /* DON'T TOUCH THIS */

As if anyone ever looks at comments and follows them :)

Anyway, let me look at this some more, I think this needs to go into the
individual buses, not the driver core. There's a lot more to initialize
than just the driver core for most busses, they should be the ones to
allow a driver to be registered or not, not the driver core, which
shouldn't care.

I have some time on Saturday (very long plane ride), where I'll take a
look at this.

thanks,

greg k-h


\
 
 \ /
  Last update: 2015-05-28 19:01    [W:0.084 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site