* [PATCH] pmdomain: core: switch to dynamic root device
@ 2026-04-24 10:40 Johan Hovold
0 siblings, 0 replies; only message in thread
From: Johan Hovold @ 2026-04-24 10:40 UTC (permalink / raw)
To: Ulf Hansson; +Cc: linux-pm, linux-kernel, Johan Hovold
Driver core expects devices to be dynamically allocated and will, for
example, complain loudly if a device that lacks a release function is
ever freed.
Use root_device_register() to allocate and register the root device
instead of open coding using a static device.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/pmdomain/core.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 4d32fc676aaf..e01884f2d7b7 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -33,9 +33,7 @@ static const struct bus_type genpd_provider_bus_type = {
};
/* The parent for genpd_provider devices. */
-static struct device genpd_provider_bus = {
- .init_name = "genpd_provider",
-};
+static struct device *genpd_provider_bus;
#define GENPD_RETRY_MAX_MS 250 /* Approximate */
@@ -2325,7 +2323,7 @@ static int genpd_alloc_data(struct generic_pm_domain *genpd)
device_initialize(&genpd->dev);
genpd->dev.release = genpd_provider_release;
genpd->dev.bus = &genpd_provider_bus_type;
- genpd->dev.parent = &genpd_provider_bus;
+ genpd->dev.parent = genpd_provider_bus;
if (!genpd_is_dev_name_fw(genpd)) {
dev_set_name(&genpd->dev, "%s", genpd->name);
@@ -3567,11 +3565,9 @@ static int __init genpd_bus_init(void)
{
int ret;
- ret = device_register(&genpd_provider_bus);
- if (ret) {
- put_device(&genpd_provider_bus);
- return ret;
- }
+ genpd_provider_bus = root_device_register("genpd_provider");
+ if (IS_ERR(genpd_provider_bus))
+ return PTR_ERR(genpd_provider_bus);
ret = bus_register(&genpd_provider_bus_type);
if (ret)
@@ -3593,7 +3589,7 @@ static int __init genpd_bus_init(void)
err_prov_bus:
bus_unregister(&genpd_provider_bus_type);
err_dev:
- device_unregister(&genpd_provider_bus);
+ root_device_unregister(genpd_provider_bus);
return ret;
}
core_initcall(genpd_bus_init);
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-24 10:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 10:40 [PATCH] pmdomain: core: switch to dynamic root device Johan Hovold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox