* [PATCH] um: virtio_uml: switch to dynamic root device
@ 2026-04-24 10:31 Johan Hovold
0 siblings, 0 replies; only message in thread
From: Johan Hovold @ 2026-04-24 10:31 UTC (permalink / raw)
To: Richard Weinberger, Anton Ivanov, Johannes Berg
Cc: Greg Kroah-Hartman, linux-um, 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 root_device_register(), which also creates a link to the
module, cannot be used as the device is registered when parsing the
module parameters which happens before the module kobject has been
set up.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
arch/um/drivers/virtio_uml.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index 7425a8548141..c43afb0af47f 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -1274,14 +1274,7 @@ static void virtio_uml_remove(struct platform_device *pdev)
/* Command line device list */
-static void vu_cmdline_release_dev(struct device *d)
-{
-}
-
-static struct device vu_cmdline_parent = {
- .init_name = "virtio-uml-cmdline",
- .release = vu_cmdline_release_dev,
-};
+static struct device *vu_cmdline_parent;
static DEFINE_MUTEX(vu_cmdline_lock);
static bool vu_cmdline_parent_registered;
@@ -1333,11 +1326,10 @@ static int vu_cmdline_set_device(const char *device)
return -EINVAL;
if (!vu_cmdline_parent_registered) {
- err = device_register(&vu_cmdline_parent);
- if (err) {
+ vu_cmdline_parent = __root_device_register("virtio-uml-cmdline", NULL);
+ if (IS_ERR(vu_cmdline_parent)) {
pr_err("Failed to register parent device!\n");
- put_device(&vu_cmdline_parent);
- return err;
+ return PTR_ERR(vu_cmdline_parent);
}
vu_cmdline_parent_registered = true;
}
@@ -1352,7 +1344,7 @@ static int vu_cmdline_set_device(const char *device)
pr_info("Registering device virtio-uml.%d id=%d at %s\n",
vu_cmdline_id, virtio_device_id, socket_path);
- pdev = platform_device_register_data(&vu_cmdline_parent, "virtio-uml",
+ pdev = platform_device_register_data(vu_cmdline_parent, "virtio-uml",
vu_cmdline_id++, &pdata,
sizeof(pdata));
err = PTR_ERR_OR_ZERO(pdev);
@@ -1393,7 +1385,7 @@ static int vu_cmdline_get(char *buffer, const struct kernel_param *kp)
buffer[0] = '\0';
if (vu_cmdline_parent_registered)
- device_for_each_child(&vu_cmdline_parent, buffer,
+ device_for_each_child(vu_cmdline_parent, buffer,
vu_cmdline_get_device);
return strlen(buffer) + 1;
}
@@ -1417,9 +1409,9 @@ static void vu_unregister_cmdline_devices(void)
guard(mutex)(&vu_cmdline_lock);
if (vu_cmdline_parent_registered) {
- device_for_each_child(&vu_cmdline_parent, NULL,
+ device_for_each_child(vu_cmdline_parent, NULL,
vu_unregister_cmdline_device);
- device_unregister(&vu_cmdline_parent);
+ root_device_unregister(vu_cmdline_parent);
vu_cmdline_parent_registered = false;
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-24 10:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 10:31 [PATCH] um: virtio_uml: switch to dynamic root device Johan Hovold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox