From: Johan Hovold <johan@kernel.org>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH 4/5] MIPS: ip22-gio: switch to dynamic root device
Date: Fri, 24 Apr 2026 12:28:48 +0200 [thread overview]
Message-ID: <20260424102849.2616035-5-johan@kernel.org> (raw)
In-Reply-To: <20260424102849.2616035-1-johan@kernel.org>
Driver core expects devices to be dynamically allocated and will, for
example, complain loudly when no release function has been provided.
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>
---
arch/mips/sgi-ip22/ip22-gio.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
index 7b7572d11250..d29067430b44 100644
--- a/arch/mips/sgi-ip22/ip22-gio.c
+++ b/arch/mips/sgi-ip22/ip22-gio.c
@@ -28,14 +28,7 @@ static struct {
{ .name = "SGI GR2/GR3", .id = 0x7f },
};
-static void gio_bus_release(struct device *dev)
-{
-}
-
-static struct device gio_bus = {
- .init_name = "gio",
- .release = &gio_bus_release,
-};
+static struct device *gio_bus;
/**
* gio_match_device - Tell if an of_device structure has a matching
@@ -99,7 +92,7 @@ EXPORT_SYMBOL_GPL(gio_release_dev);
int gio_device_register(struct gio_device *giodev)
{
giodev->dev.bus = &gio_bus_type;
- giodev->dev.parent = &gio_bus;
+ giodev->dev.parent = gio_bus;
giodev->dev.release = gio_release_dev;
return device_register(&giodev->dev);
@@ -397,11 +390,9 @@ static int __init ip22_gio_init(void)
unsigned int pbdma __maybe_unused;
int ret;
- ret = device_register(&gio_bus);
- if (ret) {
- put_device(&gio_bus);
- return ret;
- }
+ gio_bus = root_device_register("gio");
+ if (IS_ERR(gio_bus))
+ return PTR_ERR(gio_bus);
ret = bus_register(&gio_bus_type);
if (!ret) {
@@ -420,8 +411,9 @@ static int __init ip22_gio_init(void)
ip22_check_gio(1, GIO_SLOT_EXP0_BASE, SGI_GIOEXP0_IRQ);
ip22_check_gio(2, GIO_SLOT_EXP1_BASE, SGI_GIOEXP1_IRQ);
}
- } else
- device_unregister(&gio_bus);
+ } else {
+ root_device_unregister(gio_bus);
+ }
return ret;
}
--
2.53.0
next prev parent reply other threads:[~2026-04-24 10:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 10:28 [PATCH 0/5] MIPS: ip22-gio: fix leaks and replace static root Johan Hovold
2026-04-24 10:28 ` [PATCH 1/5] MIPS: ip22-gio: fix kfree() of static object Johan Hovold
2026-04-24 10:28 ` [PATCH 2/5] MIPS: ip22-gio: fix gio device memory leak Johan Hovold
2026-04-24 10:28 ` [PATCH 3/5] MIPS: ip22-gio: fix device reference leak in probe Johan Hovold
2026-04-24 10:28 ` Johan Hovold [this message]
2026-04-24 10:28 ` [PATCH 5/5] MIPS: ip22-gio: do not export device release function Johan Hovold
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=20260424102849.2616035-5-johan@kernel.org \
--to=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
/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