LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio: Directly use ida_alloc()/free()
@ 2022-05-27  7:33 keliu
  2022-05-27 10:26 ` Michael S. Tsirkin
  0 siblings, 1 reply; 2+ messages in thread
From: keliu @ 2022-05-27  7:33 UTC (permalink / raw
  To: mst, jasowang, virtualization, linux-kernel; +Cc: keliu

Use ida_alloc()/ida_free() instead of deprecated
ida_simple_get()/ida_simple_remove() .

Signed-off-by: keliu <liuke94@huawei.com>
---
 drivers/virtio/virtio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 22f15f444f75..143f94652306 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -413,7 +413,7 @@ int register_virtio_device(struct virtio_device *dev)
 	device_initialize(&dev->dev);
 
 	/* Assign a unique device index and hence name. */
-	err = ida_simple_get(&virtio_index_ida, 0, 0, GFP_KERNEL);
+	err = ida_alloc(&virtio_index_ida, GFP_KERNEL);
 	if (err < 0)
 		goto out;
 
@@ -451,7 +451,7 @@ int register_virtio_device(struct virtio_device *dev)
 out_of_node_put:
 	of_node_put(dev->dev.of_node);
 out_ida_remove:
-	ida_simple_remove(&virtio_index_ida, dev->index);
+	ida_free(&virtio_index_ida, dev->index);
 out:
 	virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
 	return err;
@@ -469,7 +469,7 @@ void unregister_virtio_device(struct virtio_device *dev)
 	int index = dev->index; /* save for after device release */
 
 	device_unregister(&dev->dev);
-	ida_simple_remove(&virtio_index_ida, index);
+	ida_free(&virtio_index_ida, index);
 }
 EXPORT_SYMBOL_GPL(unregister_virtio_device);
 
-- 
2.25.1


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

* Re: [PATCH] virtio: Directly use ida_alloc()/free()
  2022-05-27  7:33 [PATCH] virtio: Directly use ida_alloc()/free() keliu
@ 2022-05-27 10:26 ` Michael S. Tsirkin
  0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2022-05-27 10:26 UTC (permalink / raw
  To: keliu; +Cc: jasowang, virtualization, linux-kernel

On Fri, May 27, 2022 at 07:33:02AM +0000, keliu wrote:
> Use ida_alloc()/ida_free() instead of deprecated
> ida_simple_get()/ida_simple_remove() .
> 
> Signed-off-by: keliu <liuke94@huawei.com>

Please Cc people that commented on the original patch. thanks!

> ---
>  drivers/virtio/virtio.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index 22f15f444f75..143f94652306 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -413,7 +413,7 @@ int register_virtio_device(struct virtio_device *dev)
>  	device_initialize(&dev->dev);
>  
>  	/* Assign a unique device index and hence name. */
> -	err = ida_simple_get(&virtio_index_ida, 0, 0, GFP_KERNEL);
> +	err = ida_alloc(&virtio_index_ida, GFP_KERNEL);
>  	if (err < 0)
>  		goto out;
>  
> @@ -451,7 +451,7 @@ int register_virtio_device(struct virtio_device *dev)
>  out_of_node_put:
>  	of_node_put(dev->dev.of_node);
>  out_ida_remove:
> -	ida_simple_remove(&virtio_index_ida, dev->index);
> +	ida_free(&virtio_index_ida, dev->index);
>  out:
>  	virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
>  	return err;
> @@ -469,7 +469,7 @@ void unregister_virtio_device(struct virtio_device *dev)
>  	int index = dev->index; /* save for after device release */
>  
>  	device_unregister(&dev->dev);
> -	ida_simple_remove(&virtio_index_ida, index);
> +	ida_free(&virtio_index_ida, index);
>  }
>  EXPORT_SYMBOL_GPL(unregister_virtio_device);
>  
> -- 
> 2.25.1


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

end of thread, other threads:[~2022-05-27 10:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-27  7:33 [PATCH] virtio: Directly use ida_alloc()/free() keliu
2022-05-27 10:26 ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).