* [PATCH] ata: pata_parport: switch to dynamic root device
@ 2026-04-24 10:38 Johan Hovold
2026-04-24 11:18 ` Damien Le Moal
2026-04-27 9:40 ` Niklas Cassel
0 siblings, 2 replies; 4+ messages in thread
From: Johan Hovold @ 2026-04-24 10:38 UTC (permalink / raw)
To: Damien Le Moal, Niklas Cassel; +Cc: linux-ide, 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 the unlikely event that
device_register() ever fails.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/ata/pata_parport/pata_parport.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/ata/pata_parport/pata_parport.c b/drivers/ata/pata_parport/pata_parport.c
index a5b959891cb7..40baeac594a9 100644
--- a/drivers/ata/pata_parport/pata_parport.c
+++ b/drivers/ata/pata_parport/pata_parport.c
@@ -459,19 +459,11 @@ static void pata_parport_dev_release(struct device *dev)
kfree(pi);
}
-static void pata_parport_bus_release(struct device *dev)
-{
- /* nothing to do here but required to avoid warning on device removal */
-}
-
static const struct bus_type pata_parport_bus_type = {
.name = DRV_NAME,
};
-static struct device pata_parport_bus = {
- .init_name = DRV_NAME,
- .release = pata_parport_bus_release,
-};
+static struct device *pata_parport_bus;
static const struct scsi_host_template pata_parport_sht = {
PATA_PARPORT_SHT("pata_parport")
@@ -518,7 +510,7 @@ static struct pi_adapter *pi_init_one(struct parport *parport,
}
/* set up pi->dev before pi_probe_unit() so it can use dev_printk() */
- pi->dev.parent = &pata_parport_bus;
+ pi->dev.parent = pata_parport_bus;
pi->dev.bus = &pata_parport_bus_type;
pi->dev.driver = &pr->driver;
pi->dev.release = pata_parport_dev_release;
@@ -780,8 +772,9 @@ static __init int pata_parport_init(void)
return error;
}
- error = device_register(&pata_parport_bus);
- if (error) {
+ pata_parport_bus = root_device_register(DRV_NAME);
+ if (IS_ERR(pata_parport_bus)) {
+ error = PTR_ERR(pata_parport_bus);
pr_err("failed to register pata_parport bus, error: %d\n", error);
goto out_unregister_bus;
}
@@ -811,7 +804,7 @@ static __init int pata_parport_init(void)
out_remove_new:
bus_remove_file(&pata_parport_bus_type, &bus_attr_new_device);
out_unregister_dev:
- device_unregister(&pata_parport_bus);
+ root_device_unregister(pata_parport_bus);
out_unregister_bus:
bus_unregister(&pata_parport_bus_type);
return error;
@@ -822,7 +815,7 @@ static __exit void pata_parport_exit(void)
parport_unregister_driver(&pata_parport_driver);
bus_remove_file(&pata_parport_bus_type, &bus_attr_new_device);
bus_remove_file(&pata_parport_bus_type, &bus_attr_delete_device);
- device_unregister(&pata_parport_bus);
+ root_device_unregister(pata_parport_bus);
bus_unregister(&pata_parport_bus_type);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] ata: pata_parport: switch to dynamic root device
2026-04-24 10:38 [PATCH] ata: pata_parport: switch to dynamic root device Johan Hovold
@ 2026-04-24 11:18 ` Damien Le Moal
2026-04-24 14:00 ` Johan Hovold
2026-04-27 9:40 ` Niklas Cassel
1 sibling, 1 reply; 4+ messages in thread
From: Damien Le Moal @ 2026-04-24 11:18 UTC (permalink / raw)
To: Johan Hovold, Niklas Cassel; +Cc: linux-ide, linux-kernel
On 4/24/26 19:38, 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 the unlikely event that
> device_register() ever fails.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Looks OK to me.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
I suspect that this should go in for 7.1, right ?
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ata: pata_parport: switch to dynamic root device
2026-04-24 11:18 ` Damien Le Moal
@ 2026-04-24 14:00 ` Johan Hovold
0 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2026-04-24 14:00 UTC (permalink / raw)
To: Damien Le Moal; +Cc: Niklas Cassel, linux-ide, linux-kernel
On Fri, Apr 24, 2026 at 08:18:31PM +0900, Damien Le Moal wrote:
> On 4/24/26 19:38, 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 the unlikely event that
> > device_register() ever fails.
> >
> > Signed-off-by: Johan Hovold <johan@kernel.org>
>
> Looks OK to me.
>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
>
> I suspect that this should go in for 7.1, right ?
Yeah, probably, because of the reference leak which someone may try to
fix in the meantime.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ata: pata_parport: switch to dynamic root device
2026-04-24 10:38 [PATCH] ata: pata_parport: switch to dynamic root device Johan Hovold
2026-04-24 11:18 ` Damien Le Moal
@ 2026-04-27 9:40 ` Niklas Cassel
1 sibling, 0 replies; 4+ messages in thread
From: Niklas Cassel @ 2026-04-27 9:40 UTC (permalink / raw)
To: Damien Le Moal, Johan Hovold; +Cc: linux-ide, linux-kernel
On Fri, 24 Apr 2026 12:38:30 +0200, 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 the unlikely event that
> device_register() ever fails.
>
> [...]
Applied to libata/linux.git (for-7.1-fixes), thanks!
[1/1] ata: pata_parport: switch to dynamic root device
https://git.kernel.org/libata/linux/c/163f6494
Kind regards,
Niklas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-27 9:40 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:38 [PATCH] ata: pata_parport: switch to dynamic root device Johan Hovold
2026-04-24 11:18 ` Damien Le Moal
2026-04-24 14:00 ` Johan Hovold
2026-04-27 9:40 ` Niklas Cassel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox