From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F47E1A682A for ; Wed, 12 Aug 2026 14:22:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786544560; cv=none; b=F4e+vPwMPh+hyOVIHPcbs1shgBOQPUUw6JqVY9TI3+RSLy6j/y6hcP2T37rGMhZ96tN/1PvtQMeY7Ufuty9hqiYPINTmC3MCdDygoL3vQabboY4vPkYJjwlR7SX7m7MemeWmf5A6YY4IN5BPbAhUvVlhPuIP2e+rBAN64oEywvk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786544560; c=relaxed/simple; bh=+W6X/sORi2V9jBDskKzFNaYadK0a4WezLjT1WG4i/1Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=n0JdphFM8FBnLeF3Uh/x4B9J+5oHI+vDqwcvPAp4JY43JreKH6sZcotCzniI0KbrS3Lv8q+Tk4DXXafQjijpT8yttmvuai5UKyYyCbOIpXM19CYTlSg3LirhG9o1uqUtvkJrHndHz8fQbQYWmTlQaHm3gut02dvYzyKGuZNygzc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lQujvENT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lQujvENT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 231F71F000E9; Wed, 12 Aug 2026 14:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786544559; bh=LlCs/u24FiK7/ArOzq0ki4b7bwIUrnC3rdD+NfSbu4k=; h=From:To:Cc:Subject:Date; b=lQujvENTUUDqJe395lRaNSefTBfJscqxKn7jB9DTWEdUwUAJkJpMc2lQ1++lAMltt IiSSBXvYVxgbpUWEoVZn/v0oEdrLjCqYkqiTTrzBnaGP1kQjiLeSn51Z7zZa9Feobw 1pWCOGuq8b2R5lF0nvOxAlnb5VEWLEdvayJGZE0u0c+s4nC49cWErcvJ2oLHImUjYD TBLlumfr8C/OmgxGAjq4kAUCHzFqLS7SR9szirdbSPJwYTHUuqH0AI3FEeo3K24UjR WG68Hs/cwoOgyIAu9ceRd18vX+xfLxYMleGM1VxO6tIo9PIWQGlygE6r9GdVw4RKZY khKq/5+jn49Jw== Received: from johan by xi.lan with local (Exim 4.99.4) (envelope-from ) id 1wu9qm-00000000EOT-48ey; Wed, 12 Aug 2026 16:22:36 +0200 From: Johan Hovold To: Richard Weinberger , Anton Ivanov , Johannes Berg Cc: Greg Kroah-Hartman , linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH RESEND] um: virtio_uml: switch to dynamic root device Date: Wed, 12 Aug 2026 16:22:28 +0200 Message-ID: <20260812142228.55316-1-johan@kernel.org> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- It's been over three months (and one reminder) since this series was posted so resending. Johan 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.54.0