summaryrefslogtreecommitdiff
path: root/arch/um/drivers
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2026-08-12 16:22:28 +0200
committerJohannes Berg <johannes.berg@intel.com>2026-09-24 16:45:52 +0200
commite87ed6cd8e7b528362e8ecd55a4d0314a58dc21e (patch)
tree32d9e94843857579fe7b6773dae4e16542a511c1 /arch/um/drivers
parentf42c8879ebb6dbad07a7af74b02b0ee1c15b42d4 (diff)
downloadlinux-next-e87ed6cd8e7b528362e8ecd55a4d0314a58dc21e.tar.gz
linux-next-e87ed6cd8e7b528362e8ecd55a4d0314a58dc21e.zip
um: virtio_uml: switch to dynamic root device
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> Link: https://patch.msgid.link/20260812142228.55316-1-johan@kernel.org Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'arch/um/drivers')
-rw-r--r--arch/um/drivers/virtio_uml.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index 38e960bec9e6..30899ddbeae2 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;
}
}