[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220527062822-mutt-send-email-mst@kernel.org>
Date: Fri, 27 May 2022 06:29:42 -0400
From: "Michael S. Tsirkin" <mst@...hat.com>
To: keliu <liuke94@...wei.com>
Cc: mpm@...enic.com, herbert@...dor.apana.org.au, minyard@....org,
sudipm.mukherjee@...il.com, arnd@...db.de,
gregkh@...uxfoundation.org, lvivier@...hat.com,
linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers: char: Directly use ida_alloc()/free()
On Fri, May 27, 2022 at 07:44:22AM +0000, keliu wrote:
> Use ida_alloc()/ida_free() instead of deprecated
> ida_simple_get()/ida_simple_remove() .
>
> Signed-off-by: keliu <liuke94@...wei.com>
virtio bits
Acked-by: Michael S. Tsirkin <mst@...hat.com>
pls cc people that commented on a similar patch in the past though.
Thanks!
> ---
> drivers/char/hw_random/virtio-rng.c | 6 +++---
> drivers/char/ipmi/ipmi_msghandler.c | 4 ++--
> drivers/char/ppdev.c | 6 +++---
> 3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
> index e856df7e285c..0ee602963c50 100644
> --- a/drivers/char/hw_random/virtio-rng.c
> +++ b/drivers/char/hw_random/virtio-rng.c
> @@ -135,7 +135,7 @@ static int probe_common(struct virtio_device *vdev)
> if (!vi)
> return -ENOMEM;
>
> - vi->index = index = ida_simple_get(&rng_index_ida, 0, 0, GFP_KERNEL);
> + vi->index = index = ida_alloc(&rng_index_ida, GFP_KERNEL);
> if (index < 0) {
> err = index;
> goto err_ida;
> @@ -165,7 +165,7 @@ static int probe_common(struct virtio_device *vdev)
> return 0;
>
> err_find:
> - ida_simple_remove(&rng_index_ida, index);
> + ida_free(&rng_index_ida, index);
> err_ida:
> kfree(vi);
> return err;
> @@ -183,7 +183,7 @@ static void remove_common(struct virtio_device *vdev)
> hwrng_unregister(&vi->hwrng);
> virtio_reset_device(vdev);
> vdev->config->del_vqs(vdev);
> - ida_simple_remove(&rng_index_ida, vi->index);
> + ida_free(&rng_index_ida, vi->index);
> kfree(vi);
> }
>
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index f1827257ef0e..c1584ed24a6b 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -3018,7 +3018,7 @@ static void cleanup_bmc_work(struct work_struct *work)
> int id = bmc->pdev.id; /* Unregister overwrites id */
>
> platform_device_unregister(&bmc->pdev);
> - ida_simple_remove(&ipmi_bmc_ida, id);
> + ida_free(&ipmi_bmc_ida, id);
> }
>
> static void
> @@ -3134,7 +3134,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
>
> bmc->pdev.name = "ipmi_bmc";
>
> - rv = ida_simple_get(&ipmi_bmc_ida, 0, 0, GFP_KERNEL);
> + rv = ida_alloc(&ipmi_bmc_ida, GFP_KERNEL);
> if (rv < 0) {
> kfree(bmc);
> goto out;
> diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
> index 38b46c7d1737..f6024d97fe70 100644
> --- a/drivers/char/ppdev.c
> +++ b/drivers/char/ppdev.c
> @@ -299,7 +299,7 @@ static int register_device(int minor, struct pp_struct *pp)
> goto err;
> }
>
> - index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
> + index = ida_alloc(&ida_index, GFP_KERNEL);
> memset(&ppdev_cb, 0, sizeof(ppdev_cb));
> ppdev_cb.irq_func = pp_irq;
> ppdev_cb.flags = (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0;
> @@ -310,7 +310,7 @@ static int register_device(int minor, struct pp_struct *pp)
> if (!pdev) {
> pr_warn("%s: failed to register device!\n", name);
> rc = -ENXIO;
> - ida_simple_remove(&ida_index, index);
> + ida_free(&ida_index, index);
> goto err;
> }
>
> @@ -750,7 +750,7 @@ static int pp_release(struct inode *inode, struct file *file)
>
> if (pp->pdev) {
> parport_unregister_device(pp->pdev);
> - ida_simple_remove(&ida_index, pp->index);
> + ida_free(&ida_index, pp->index);
> pp->pdev = NULL;
> pr_debug(CHRDEV "%x: unregistered pardevice\n", minor);
> }
> --
> 2.25.1
Powered by blists - more mailing lists