* [PATCH] driver: base: class: remove device from class on registration
@ 2025-03-20 5:20 Ahmad Fatoum
0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2025-03-20 5:20 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
class_remove_device is the exception and normally, a device class
doesn't change for the lifetime of a device after it's set the first
time and removal from a class is done alongside removal of the device
itself.
Let's therefore move the removal from class into core driver code.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/base/class.c | 11 -----------
drivers/base/driver.c | 2 ++
drivers/watchdog/wd_core.c | 2 +-
include/device.h | 2 --
net/eth.c | 2 --
5 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/drivers/base/class.c b/drivers/base/class.c
index d0765e496f9e..b7cc58ce0750 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -48,14 +48,3 @@ int class_register_device(struct class *class,
class_add_device(class, class_dev);
return 0;
}
-
-void class_unregister_device(struct device *class_dev)
-{
- list_del(&class_dev->class_list);
- unregister_device(class_dev);
-}
-
-void class_remove_device(struct class *class, struct device *dev)
-{
- list_del(&dev->class_list);
-}
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 603fc9d9cb0a..6363b3948f1d 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -265,6 +265,7 @@ int register_device(struct device *new_device)
INIT_LIST_HEAD(&new_device->parameters);
INIT_LIST_HEAD(&new_device->active);
INIT_LIST_HEAD(&new_device->bus_list);
+ INIT_LIST_HEAD(&new_device->class_list);
if (new_device->bus) {
if (!new_device->parent)
@@ -318,6 +319,7 @@ int unregister_device(struct device *old_dev)
list_del(&old_dev->list);
list_del(&old_dev->bus_list);
+ list_del(&old_dev->class_list);
list_del(&old_dev->active);
/* remove device from parents child list */
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index 27371672f39c..6e239edf612d 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -255,7 +255,7 @@ int watchdog_deregister(struct watchdog *wd)
poller_async_unregister(&wd->poller);
}
- class_remove_device(&watchdog_class, &wd->dev);
+ list_del_init(&wd->dev.class_list);
return 0;
}
diff --git a/include/device.h b/include/device.h
index d3936d3b3ad6..e0c130551f9a 100644
--- a/include/device.h
+++ b/include/device.h
@@ -128,11 +128,9 @@ void class_register(struct class *class);
pure_initcall(register_##_name);
int class_add_device(struct class *class, struct device *dev);
-void class_remove_device(struct class *class, struct device *dev);
int class_register_device(struct class *class, struct device *class_dev,
const char *name);
-void class_unregister_device(struct device *class_dev);
extern struct list_head class_list;
#define class_for_each_device(class, dev) list_for_each_entry((dev), &(class)->devices, class_list)
diff --git a/net/eth.c b/net/eth.c
index e4025753518c..bc2527de3670 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -539,8 +539,6 @@ void eth_unregister(struct eth_device *edev)
if (IS_ENABLED(CONFIG_OFDEVICE))
free_const(edev->nodepath);
- class_remove_device(ð_class, &edev->dev);
-
free(edev->devname);
unregister_device(&edev->dev);
--
2.39.5
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-03-20 5:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-20 5:20 [PATCH] driver: base: class: remove device from class on registration Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox