* [PATCH] maple: switch to dynamic root device
@ 2026-04-24 10:41 Johan Hovold
2026-04-24 19:08 ` Artur Rojek
0 siblings, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2026-04-24 10:41 UTC (permalink / raw)
To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz
Cc: linux-sh, linux-kernel, Johan Hovold
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] maple: switch to dynamic root device
2026-04-24 10:41 [PATCH] maple: switch to dynamic root device Johan Hovold
@ 2026-04-24 19:08 ` Artur Rojek
2026-04-24 19:59 ` John Paul Adrian Glaubitz
0 siblings, 1 reply; 4+ messages in thread
From: Artur Rojek @ 2026-04-24 19:08 UTC (permalink / raw)
To: Johan Hovold
Cc: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz, linux-sh,
linux-kernel
On 2026-04-24 12:41, Johan Hovold wrote:
> 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>
Hi Johan,
thanks for the patch. Verified on real hardware. LGTM:
Acked-by: Artur Rojek <contact@artur-rojek.eu>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] maple: switch to dynamic root device
2026-04-24 19:08 ` Artur Rojek
@ 2026-04-24 19:59 ` John Paul Adrian Glaubitz
2026-04-24 21:09 ` Artur Rojek
0 siblings, 1 reply; 4+ messages in thread
From: John Paul Adrian Glaubitz @ 2026-04-24 19:59 UTC (permalink / raw)
To: Artur Rojek, Johan Hovold
Cc: Yoshinori Sato, Rich Felker, linux-sh, linux-kernel
Hi Artur,
On Fri, 2026-04-24 at 21:08 +0200, Artur Rojek wrote:
> On 2026-04-24 12:41, Johan Hovold wrote:
> > 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>
>
> Hi Johan,
>
> thanks for the patch. Verified on real hardware. LGTM:
>
> Acked-by: Artur Rojek <contact@artur-rojek.eu>
Maybe add a Tested-by as well.
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] maple: switch to dynamic root device
2026-04-24 19:59 ` John Paul Adrian Glaubitz
@ 2026-04-24 21:09 ` Artur Rojek
0 siblings, 0 replies; 4+ messages in thread
From: Artur Rojek @ 2026-04-24 21:09 UTC (permalink / raw)
To: John Paul Adrian Glaubitz
Cc: Johan Hovold, Yoshinori Sato, Rich Felker, linux-sh, linux-kernel
On 2026-04-24 21:59, John Paul Adrian Glaubitz wrote:
> Hi Artur,
>
> On Fri, 2026-04-24 at 21:08 +0200, Artur Rojek wrote:
>> On 2026-04-24 12:41, Johan Hovold wrote:
>> > 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>
>>
>> Hi Johan,
>>
>> thanks for the patch. Verified on real hardware. LGTM:
>>
>> Acked-by: Artur Rojek <contact@artur-rojek.eu>
>
> Maybe add a Tested-by as well.
Tested-by: Artur Rojek <contact@artur-rojek.eu>
>
> Adrian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-24 21:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 10:41 [PATCH] maple: switch to dynamic root device Johan Hovold
2026-04-24 19:08 ` Artur Rojek
2026-04-24 19:59 ` John Paul Adrian Glaubitz
2026-04-24 21:09 ` Artur Rojek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox