From: Corey Minyard <minyard@acm.org>
To: keliu <liuke94@huawei.com>
Cc: mpm@selenic.com, herbert@gondor.apana.org.au,
sudipm.mukherjee@gmail.com, arnd@arndb.de,
gregkh@linuxfoundation.org, mst@redhat.com, lvivier@redhat.com,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: char: Directly use ida_alloc()/free()
Date: Fri, 27 May 2022 06:58:45 -0500 [thread overview]
Message-ID: <20220527115845.GJ3767252@minyard.net> (raw)
In-Reply-To: <20220527074422.2475104-1-liuke94@huawei.com>
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@huawei.com>
> ---
> 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(-)
If you want this to go into individual maintainer trees, you will need
to split it up. Otherwise, how are you planning to get this change
into the kernel?
-corey
>
> 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
>
prev parent reply other threads:[~2022-05-27 12:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 7:44 [PATCH] drivers: char: Directly use ida_alloc()/free() keliu
2022-05-27 10:29 ` Michael S. Tsirkin
2022-05-27 11:58 ` Corey Minyard [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220527115845.GJ3767252@minyard.net \
--to=minyard@acm.org \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuke94@huawei.com \
--cc=lvivier@redhat.com \
--cc=mpm@selenic.com \
--cc=mst@redhat.com \
--cc=sudipm.mukherjee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox