From: Johan Hovold <johan@kernel.org>
To: Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH] maple: switch to dynamic root device
Date: Fri, 24 Apr 2026 12:41:42 +0200 [thread overview]
Message-ID: <20260424104142.2617115-1-johan@kernel.org> (raw)
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.
Note that this also fixes a reference leak in case device_register()
fails which may be flagged by static checkers.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/sh/maple/maple.c | 30 +++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 5585f220e495..7c0f847ee368 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -44,7 +44,7 @@ static LIST_HEAD(maple_sentq);
static DEFINE_MUTEX(maple_wlist_lock);
static struct maple_driver maple_unsupported_device;
-static struct device maple_bus;
+static struct device *maple_bus;
static int subdevice_map[MAPLE_PORTS];
static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
static unsigned long maple_pnp_time;
@@ -229,7 +229,7 @@ static struct maple_device *maple_alloc_dev(int port, int unit)
return NULL;
}
mdev->dev.bus = &maple_bus_type;
- mdev->dev.parent = &maple_bus;
+ mdev->dev.parent = maple_bus;
init_waitqueue_head(&mdev->maple_wait);
return mdev;
}
@@ -761,10 +761,6 @@ static int maple_match_bus_driver(struct device *devptr,
return 0;
}
-static void maple_bus_release(struct device *dev)
-{
-}
-
static struct maple_driver maple_unsupported_device = {
.drv = {
.name = "maple_unsupported_device",
@@ -779,11 +775,6 @@ static const struct bus_type maple_bus_type = {
.match = maple_match_bus_driver,
};
-static struct device maple_bus = {
- .init_name = "maple",
- .release = maple_bus_release,
-};
-
static int __init maple_bus_init(void)
{
int retval, i;
@@ -791,9 +782,11 @@ static int __init maple_bus_init(void)
__raw_writel(0, MAPLE_ENABLE);
- retval = device_register(&maple_bus);
- if (retval)
+ maple_bus = root_device_register("maple");
+ if (IS_ERR(maple_bus)) {
+ retval = PTR_ERR(maple_bus);
goto cleanup;
+ }
retval = bus_register(&maple_bus_type);
if (retval)
@@ -806,22 +799,21 @@ static int __init maple_bus_init(void)
/* allocate memory for maple bus dma */
retval = maple_get_dma_buffer();
if (retval) {
- dev_err(&maple_bus, "failed to allocate DMA buffers\n");
+ dev_err(maple_bus, "failed to allocate DMA buffers\n");
goto cleanup_basic;
}
/* set up DMA interrupt handler */
retval = maple_set_dma_interrupt_handler();
if (retval) {
- dev_err(&maple_bus, "bus failed to grab maple "
- "DMA IRQ\n");
+ dev_err(maple_bus, "bus failed to grab maple DMA IRQ\n");
goto cleanup_dma;
}
/* set up VBLANK interrupt handler */
retval = maple_set_vblank_interrupt_handler();
if (retval) {
- dev_err(&maple_bus, "bus failed to grab VBLANK IRQ\n");
+ dev_err(maple_bus, "bus failed to grab VBLANK IRQ\n");
goto cleanup_irq;
}
@@ -855,7 +847,7 @@ static int __init maple_bus_init(void)
maple_pnp_time = jiffies + HZ;
/* prepare initial queue */
maple_send();
- dev_info(&maple_bus, "bus core now registered\n");
+ dev_info(maple_bus, "bus core now registered\n");
return 0;
@@ -878,7 +870,7 @@ static int __init maple_bus_init(void)
bus_unregister(&maple_bus_type);
cleanup_device:
- device_unregister(&maple_bus);
+ root_device_unregister(maple_bus);
cleanup:
printk(KERN_ERR "Maple bus registration failed\n");
--
2.53.0
next reply other threads:[~2026-04-24 10:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 10:41 Johan Hovold [this message]
2026-04-24 19:08 ` [PATCH] maple: switch to dynamic root device Artur Rojek
2026-04-24 19:59 ` John Paul Adrian Glaubitz
2026-04-24 21:09 ` Artur Rojek
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=20260424104142.2617115-1-johan@kernel.org \
--to=johan@kernel.org \
--cc=dalias@libc.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=ysato@users.sourceforge.jp \
/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