public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] vdpa_sim: switch to dynamic root device
@ 2026-04-24 10:47 Johan Hovold
  2026-04-24 10:47 ` [PATCH 1/2] vdpa_sim_blk: " Johan Hovold
  2026-04-24 10:47 ` [PATCH 2/2] vdpa_sim_net: " Johan Hovold
  0 siblings, 2 replies; 5+ messages in thread
From: Johan Hovold @ 2026-04-24 10:47 UTC (permalink / raw)
  To: Michael S . Tsirkin, Jason Wang
  Cc: Xuan Zhuo, Eugenio Pérez, virtualization, linux-kernel,
	Johan Hovold

This series replaces the statically allocated VDPA SIM root devices.

Johan


Johan Hovold (2):
  vdpa_sim_blk: switch to dynamic root device
  vdpa_sim_net: switch to dynamic root device

 drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 24 ++++++++----------------
 drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 23 +++++++----------------
 2 files changed, 15 insertions(+), 32 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] vdpa_sim_blk: switch to dynamic root device
  2026-04-24 10:47 [PATCH 0/2] vdpa_sim: switch to dynamic root device Johan Hovold
@ 2026-04-24 10:47 ` Johan Hovold
  2026-04-27  1:20   ` Jason Wang
  2026-04-24 10:47 ` [PATCH 2/2] vdpa_sim_net: " Johan Hovold
  1 sibling, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2026-04-24 10:47 UTC (permalink / raw)
  To: Michael S . Tsirkin, Jason Wang
  Cc: Xuan Zhuo, Eugenio Pérez, virtualization, 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.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
index b137f3679343..f70f454dde8e 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
@@ -397,14 +397,7 @@ static void vdpasim_blk_free(struct vdpasim *vdpasim)
 		kvfree(blk->buffer);
 }
 
-static void vdpasim_blk_mgmtdev_release(struct device *dev)
-{
-}
-
-static struct device vdpasim_blk_mgmtdev = {
-	.init_name = "vdpasim_blk",
-	.release = vdpasim_blk_mgmtdev_release,
-};
+static struct device *vdpasim_blk_mgmtdev;
 
 static int vdpasim_blk_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
 			       const struct vdpa_dev_set_config *config)
@@ -475,7 +468,6 @@ static struct virtio_device_id id_table[] = {
 };
 
 static struct vdpa_mgmt_dev mgmt_dev = {
-	.device = &vdpasim_blk_mgmtdev,
 	.id_table = id_table,
 	.ops = &vdpasim_blk_mgmtdev_ops,
 };
@@ -484,12 +476,11 @@ static int __init vdpasim_blk_init(void)
 {
 	int ret;
 
-	ret = device_register(&vdpasim_blk_mgmtdev);
-	if (ret) {
-		put_device(&vdpasim_blk_mgmtdev);
-		return ret;
-	}
+	vdpasim_blk_mgmtdev = root_device_register("vdpasim_blk");
+	if (IS_ERR(vdpasim_blk_mgmtdev))
+		return PTR_ERR(vdpasim_blk_mgmtdev);
 
+	mgmt_dev.device = vdpasim_blk_mgmtdev;
 	ret = vdpa_mgmtdev_register(&mgmt_dev);
 	if (ret)
 		goto parent_err;
@@ -507,7 +498,8 @@ static int __init vdpasim_blk_init(void)
 mgmt_dev_err:
 	vdpa_mgmtdev_unregister(&mgmt_dev);
 parent_err:
-	device_unregister(&vdpasim_blk_mgmtdev);
+	root_device_unregister(vdpasim_blk_mgmtdev);
+
 	return ret;
 }
 
@@ -515,7 +507,7 @@ static void __exit vdpasim_blk_exit(void)
 {
 	kvfree(shared_buffer);
 	vdpa_mgmtdev_unregister(&mgmt_dev);
-	device_unregister(&vdpasim_blk_mgmtdev);
+	root_device_unregister(vdpasim_blk_mgmtdev);
 }
 
 module_init(vdpasim_blk_init)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] vdpa_sim_net: switch to dynamic root device
  2026-04-24 10:47 [PATCH 0/2] vdpa_sim: switch to dynamic root device Johan Hovold
  2026-04-24 10:47 ` [PATCH 1/2] vdpa_sim_blk: " Johan Hovold
@ 2026-04-24 10:47 ` Johan Hovold
  2026-04-27  1:20   ` Jason Wang
  1 sibling, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2026-04-24 10:47 UTC (permalink / raw)
  To: Michael S . Tsirkin, Jason Wang
  Cc: Xuan Zhuo, Eugenio Pérez, virtualization, 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.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
index 6caf09a1907b..29fd14ce5860 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
@@ -453,14 +453,7 @@ static void vdpasim_net_free(struct vdpasim *vdpasim)
 	kvfree(net->buffer);
 }
 
-static void vdpasim_net_mgmtdev_release(struct device *dev)
-{
-}
-
-static struct device vdpasim_net_mgmtdev = {
-	.init_name = "vdpasim_net",
-	.release = vdpasim_net_mgmtdev_release,
-};
+static struct device *vdpasim_net_mgmtdev;
 
 static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
 			       const struct vdpa_dev_set_config *config)
@@ -538,7 +531,6 @@ static struct virtio_device_id id_table[] = {
 };
 
 static struct vdpa_mgmt_dev mgmt_dev = {
-	.device = &vdpasim_net_mgmtdev,
 	.id_table = id_table,
 	.ops = &vdpasim_net_mgmtdev_ops,
 	.config_attr_mask = (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR |
@@ -552,26 +544,25 @@ static int __init vdpasim_net_init(void)
 {
 	int ret;
 
-	ret = device_register(&vdpasim_net_mgmtdev);
-	if (ret) {
-		put_device(&vdpasim_net_mgmtdev);
-		return ret;
-	}
+	vdpasim_net_mgmtdev = root_device_register("vdpasim_net");
+	if (IS_ERR(vdpasim_net_mgmtdev))
+		return PTR_ERR(vdpasim_net_mgmtdev);
 
+	mgmt_dev.device = vdpasim_net_mgmtdev;
 	ret = vdpa_mgmtdev_register(&mgmt_dev);
 	if (ret)
 		goto parent_err;
 	return 0;
 
 parent_err:
-	device_unregister(&vdpasim_net_mgmtdev);
+	root_device_unregister(vdpasim_net_mgmtdev);
 	return ret;
 }
 
 static void __exit vdpasim_net_exit(void)
 {
 	vdpa_mgmtdev_unregister(&mgmt_dev);
-	device_unregister(&vdpasim_net_mgmtdev);
+	root_device_unregister(vdpasim_net_mgmtdev);
 }
 
 module_init(vdpasim_net_init);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] vdpa_sim_blk: switch to dynamic root device
  2026-04-24 10:47 ` [PATCH 1/2] vdpa_sim_blk: " Johan Hovold
@ 2026-04-27  1:20   ` Jason Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Wang @ 2026-04-27  1:20 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Michael S . Tsirkin, Xuan Zhuo, Eugenio Pérez,
	virtualization, linux-kernel

On Fri, Apr 24, 2026 at 6:48 PM Johan Hovold <johan@kernel.org> 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.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] vdpa_sim_net: switch to dynamic root device
  2026-04-24 10:47 ` [PATCH 2/2] vdpa_sim_net: " Johan Hovold
@ 2026-04-27  1:20   ` Jason Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Wang @ 2026-04-27  1:20 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Michael S . Tsirkin, Xuan Zhuo, Eugenio Pérez,
	virtualization, linux-kernel

On Fri, Apr 24, 2026 at 6:47 PM Johan Hovold <johan@kernel.org> 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.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---

Acked-by: Jason Wang <jasowang@redhat.com>

Thanks


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-27  1:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 10:47 [PATCH 0/2] vdpa_sim: switch to dynamic root device Johan Hovold
2026-04-24 10:47 ` [PATCH 1/2] vdpa_sim_blk: " Johan Hovold
2026-04-27  1:20   ` Jason Wang
2026-04-24 10:47 ` [PATCH 2/2] vdpa_sim_net: " Johan Hovold
2026-04-27  1:20   ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox