public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Bjorn Andersson <andersson@kernel.org>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-remoteproc@vger.kernel.org
Subject: Re: [PATCH] rpmsg: Remove usage of the deprecated ida_simple_xx() API
Date: Mon, 15 Jan 2024 11:34:41 -0700	[thread overview]
Message-ID: <ZaV6wd8GghPy+Ti7@p14s> (raw)
In-Reply-To: <c09ee5b66d451bf97d14c167048549aa0824ee06.1705225049.git.christophe.jaillet@wanadoo.fr>

Hi Christophe,

On Sun, Jan 14, 2024 at 10:37:43AM +0100, Christophe JAILLET wrote:
> ida_alloc() and ida_free() should be preferred to the deprecated
> ida_simple_get() and ida_simple_remove().
> 
> Note that the upper limit of ida_simple_get() is exclusive, but the one of
> ida_alloc_max() is inclusive. So a -1 has been added when needed.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/rpmsg/rpmsg_char.c | 12 ++++++------
>  drivers/rpmsg/rpmsg_ctrl.c | 12 ++++++------
>  2 files changed, 12 insertions(+), 12 deletions(-)
> 

I will apply this patch when the next rc1 comes out.

Thanks,
Mathieu

> diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
> index 09833ad05da7..1cb8d7474428 100644
> --- a/drivers/rpmsg/rpmsg_char.c
> +++ b/drivers/rpmsg/rpmsg_char.c
> @@ -399,8 +399,8 @@ static void rpmsg_eptdev_release_device(struct device *dev)
>  {
>  	struct rpmsg_eptdev *eptdev = dev_to_eptdev(dev);
>  
> -	ida_simple_remove(&rpmsg_ept_ida, dev->id);
> -	ida_simple_remove(&rpmsg_minor_ida, MINOR(eptdev->dev.devt));
> +	ida_free(&rpmsg_ept_ida, dev->id);
> +	ida_free(&rpmsg_minor_ida, MINOR(eptdev->dev.devt));
>  	kfree(eptdev);
>  }
>  
> @@ -441,12 +441,12 @@ static int rpmsg_chrdev_eptdev_add(struct rpmsg_eptdev *eptdev, struct rpmsg_cha
>  
>  	eptdev->chinfo = chinfo;
>  
> -	ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL);
> +	ret = ida_alloc_max(&rpmsg_minor_ida, RPMSG_DEV_MAX - 1, GFP_KERNEL);
>  	if (ret < 0)
>  		goto free_eptdev;
>  	dev->devt = MKDEV(MAJOR(rpmsg_major), ret);
>  
> -	ret = ida_simple_get(&rpmsg_ept_ida, 0, 0, GFP_KERNEL);
> +	ret = ida_alloc(&rpmsg_ept_ida, GFP_KERNEL);
>  	if (ret < 0)
>  		goto free_minor_ida;
>  	dev->id = ret;
> @@ -462,9 +462,9 @@ static int rpmsg_chrdev_eptdev_add(struct rpmsg_eptdev *eptdev, struct rpmsg_cha
>  	return ret;
>  
>  free_ept_ida:
> -	ida_simple_remove(&rpmsg_ept_ida, dev->id);
> +	ida_free(&rpmsg_ept_ida, dev->id);
>  free_minor_ida:
> -	ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt));
> +	ida_free(&rpmsg_minor_ida, MINOR(dev->devt));
>  free_eptdev:
>  	put_device(dev);
>  	kfree(eptdev);
> diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c
> index 433253835690..c312794ba4b3 100644
> --- a/drivers/rpmsg/rpmsg_ctrl.c
> +++ b/drivers/rpmsg/rpmsg_ctrl.c
> @@ -130,8 +130,8 @@ static void rpmsg_ctrldev_release_device(struct device *dev)
>  {
>  	struct rpmsg_ctrldev *ctrldev = dev_to_ctrldev(dev);
>  
> -	ida_simple_remove(&rpmsg_ctrl_ida, dev->id);
> -	ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt));
> +	ida_free(&rpmsg_ctrl_ida, dev->id);
> +	ida_free(&rpmsg_minor_ida, MINOR(dev->devt));
>  	kfree(ctrldev);
>  }
>  
> @@ -156,12 +156,12 @@ static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev)
>  	cdev_init(&ctrldev->cdev, &rpmsg_ctrldev_fops);
>  	ctrldev->cdev.owner = THIS_MODULE;
>  
> -	ret = ida_simple_get(&rpmsg_minor_ida, 0, RPMSG_DEV_MAX, GFP_KERNEL);
> +	ret = ida_alloc_max(&rpmsg_minor_ida, RPMSG_DEV_MAX - 1, GFP_KERNEL);
>  	if (ret < 0)
>  		goto free_ctrldev;
>  	dev->devt = MKDEV(MAJOR(rpmsg_major), ret);
>  
> -	ret = ida_simple_get(&rpmsg_ctrl_ida, 0, 0, GFP_KERNEL);
> +	ret = ida_alloc(&rpmsg_ctrl_ida, GFP_KERNEL);
>  	if (ret < 0)
>  		goto free_minor_ida;
>  	dev->id = ret;
> @@ -179,9 +179,9 @@ static int rpmsg_ctrldev_probe(struct rpmsg_device *rpdev)
>  	return ret;
>  
>  free_ctrl_ida:
> -	ida_simple_remove(&rpmsg_ctrl_ida, dev->id);
> +	ida_free(&rpmsg_ctrl_ida, dev->id);
>  free_minor_ida:
> -	ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt));
> +	ida_free(&rpmsg_minor_ida, MINOR(dev->devt));
>  free_ctrldev:
>  	put_device(dev);
>  	kfree(ctrldev);
> -- 
> 2.43.0
> 

      reply	other threads:[~2024-01-15 18:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-14  9:37 [PATCH] rpmsg: Remove usage of the deprecated ida_simple_xx() API Christophe JAILLET
2024-01-15 18:34 ` Mathieu Poirier [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=ZaV6wd8GghPy+Ti7@p14s \
    --to=mathieu.poirier@linaro.org \
    --cc=andersson@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    /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