Re: [PATCH 07/18] driver: Add unregister_driver()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 20, 2023 at 04:43:08PM +0100, Ahmad Fatoum wrote:
> On 20.03.23 16:29, Sascha Hauer wrote:
> > Registering drivers is one thing, getting rid of them another. Add
> > unregister_driver() which is used in the coming USB gadget update.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
> > ---
> >  drivers/base/driver.c | 16 ++++++++++++++++
> >  include/driver.h      |  2 ++
> >  2 files changed, 18 insertions(+)
> > 
> > diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> > index efbffcdddb..719920ec67 100644
> > --- a/drivers/base/driver.c
> > +++ b/drivers/base/driver.c
> > @@ -405,6 +405,22 @@ int register_driver(struct driver *drv)
> >  }
> >  EXPORT_SYMBOL(register_driver);
> >  
> > +void unregister_driver(struct driver *drv)
> > +{
> > +	struct device *dev;
> > +
> > +	list_del(&drv->list);
> > +	list_del(&drv->bus_list);
> > +
> > +	bus_for_each_device(drv->bus, dev) {
> > +		if (dev->driver == drv) {
> > +			drv->bus->remove(dev);
> 
> I think drv->bus->remove may be NULL here and you need to guard against that.

drv->bus->remove is non NULL for all buses and in unregister_device() it
is also assumed to be non NULL.

> While at it, could you switch commands/devunbind.c to use this new function?

devunbind can only unregister devices. I don't think I can do anything
with unregister_driver() there.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux