[PATCH 07/18] driver: Add unregister_driver()
Sascha Hauer
s.hauer at pengutronix.de
Mon Mar 20 08:29:30 PDT 2023
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 at 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);
+ 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
--
2.30.2
More information about the barebox
mailing list