From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 07/18] driver: Add unregister_driver()
Date: Mon, 20 Mar 2023 16:43:08 +0100 [thread overview]
Message-ID: <6434964e-16c1-7b01-7244-f38767be4570@pengutronix.de> (raw)
In-Reply-To: <20230320152941.3155428-8-s.hauer@pengutronix.de>
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@pengutronix.de>
> ---
> 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.
While at it, could you switch commands/devunbind.c to use this new function?
Thanks,
Ahmad
> + dev->driver = NULL;
> + list_del(&dev->active);
> + }
> + }
> +}
> +
> struct resource *dev_get_resource(struct device *dev, unsigned long type,
> int num)
> {
> diff --git a/include/driver.h b/include/driver.h
> index 2cf0190699..5605a3db24 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -137,6 +137,8 @@ struct driver {
> /* Register devices and drivers.
> */
> int register_driver(struct driver *);
> +void unregister_driver(struct driver *drv);
> +
> int register_device(struct device *);
>
> /* manualy probe a device
--
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 |
next prev parent reply other threads:[~2023-03-20 15:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 15:29 [PATCH 00/18] USB gadget overhaul Sascha Hauer
2023-03-20 15:29 ` [PATCH 01/18] usb: gadget: fastboot: Allocate IN requests when needed Sascha Hauer
2023-03-20 15:29 ` [PATCH 02/18] usb: gadget: drop gadget_chips.h Sascha Hauer
2023-03-20 15:29 ` [PATCH 03/18] usb: gadget: move files to place where Linux has them Sascha Hauer
2023-03-20 15:29 ` [PATCH 04/18] usb: move include " Sascha Hauer
2023-03-20 15:29 ` [PATCH 05/18] usb: ch9: Update from Linux Kernel Sascha Hauer
2023-03-20 15:29 ` [PATCH 06/18] phy: Add mode setting support Sascha Hauer
2023-03-20 15:29 ` [PATCH 07/18] driver: Add unregister_driver() Sascha Hauer
2023-03-20 15:43 ` Ahmad Fatoum [this message]
2023-03-21 8:07 ` Sascha Hauer
2023-03-20 15:29 ` [PATCH 08/18] usb: gadget: Update core to Linux-6.3-rc2 Sascha Hauer
2023-03-20 15:29 ` [PATCH 09/18] uuid.h: sync with Linux-6.3-rc2 Sascha Hauer
2023-03-20 15:29 ` [PATCH 10/18] usb: gadget: Add super-speed-plus descriptors Sascha Hauer
2023-03-20 15:29 ` [PATCH 11/18] usb: gadget: update composite.c from Linux-6.3-rc2 Sascha Hauer
2023-03-20 15:29 ` [PATCH 12/18] Add dev_WARN_ONCE() Sascha Hauer
2023-03-20 15:29 ` [PATCH 13/18] usb: dwc3: sync with Linux-6.3-rc2 Sascha Hauer
2023-03-20 15:29 ` [PATCH 14/18] usb: gadget: dfu: Assign super speed descriptors Sascha Hauer
2023-03-20 15:29 ` [PATCH 15/18] usb: gadget: fastboot: Add " Sascha Hauer
2023-03-22 8:28 ` Johannes Zink
2023-03-20 15:29 ` [PATCH 16/18] usb: gadget: mass storage: " Sascha Hauer
2023-03-20 15:29 ` [PATCH 17/18] usb: gadget: u_serial: Put back to list if shutdown Sascha Hauer
2023-03-20 15:29 ` [PATCH 18/18] usb: gadget multi: support USB Super Speed Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6434964e-16c1-7b01-7244-f38767be4570@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox