From: Johan Hovold <johan@kernel.org>
To: Ulf Hansson <ulfh@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH] pmdomain: core: switch to dynamic root device
Date: Fri, 24 Apr 2026 12:40:50 +0200 [thread overview]
Message-ID: <20260424104050.2617041-1-johan@kernel.org> (raw)
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
reply other threads:[~2026-04-24 10:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260424104050.2617041-1-johan@kernel.org \
--to=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=ulfh@kernel.org \
/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