* [PATCH] driver: base: report driver remove before, not after operation
@ 2025-12-11 20:37 Ahmad Fatoum
2025-12-15 7:20 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-12-11 20:37 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Calling pr_report_probe() after the removal is unexpected as for
initcalls and probes, we print before to make hangs or crashes
easier to pinpoint.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/base/driver.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 753e06963b16..102e7ea2c0dd 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -659,15 +659,25 @@ int dev_add_alias(struct device *dev, const char *fmt, ...)
}
EXPORT_SYMBOL_GPL(dev_add_alias);
-bool device_remove(struct device *dev)
+typedef void (*dev_remove_op_t)(struct device *dev);
+
+static dev_remove_op_t get_device_remove(struct device *dev)
{
if (dev->bus && dev->bus->remove)
- dev->bus->remove(dev);
+ return dev->bus->remove;
else if (dev->driver->remove)
- dev->driver->remove(dev);
+ return dev->driver->remove;
else
- return false; /* nothing to do */
+ return NULL;
+}
+bool device_remove(struct device *dev)
+{
+ dev_remove_op_t remove = get_device_remove(dev);
+ if (!remove)
+ return false; /* nothing to do */
+
+ remove(dev);
return true;
}
EXPORT_SYMBOL_GPL(device_remove);
@@ -677,8 +687,11 @@ static void devices_shutdown(void)
struct device *dev;
list_for_each_entry(dev, &active_device_list, active) {
- if (device_remove(dev))
+ dev_remove_op_t remove = get_device_remove(dev);
+ if (remove) {
pr_report_probe("%*sremove-> %s\n", 1 * 4, "", dev_name(dev));
+ remove(dev);
+ }
dev->driver = NULL;
}
}
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] driver: base: report driver remove before, not after operation
2025-12-11 20:37 [PATCH] driver: base: report driver remove before, not after operation Ahmad Fatoum
@ 2025-12-15 7:20 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-12-15 7:20 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Thu, 11 Dec 2025 21:37:07 +0100, Ahmad Fatoum wrote:
> Calling pr_report_probe() after the removal is unexpected as for
> initcalls and probes, we print before to make hangs or crashes
> easier to pinpoint.
>
>
Applied, thanks!
[1/1] driver: base: report driver remove before, not after operation
https://git.pengutronix.de/cgit/barebox/commit/?id=97fd52dc91b2 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-15 7:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-11 20:37 [PATCH] driver: base: report driver remove before, not after operation Ahmad Fatoum
2025-12-15 7:20 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox