NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	"Ira Weiny" <ira.weiny@intel.com>
Cc: <linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>,
	<nvdimm@lists.linux.dev>
Subject: Re: [PATCH] nvdimm: Remove usage of the deprecated ida_simple_xx() API
Date: Mon, 11 Dec 2023 18:26:13 -0700	[thread overview]
Message-ID: <60c10003-083e-4025-98a3-78e78701043d@intel.com> (raw)
In-Reply-To: <50719568e4108f65f3b989ba05c1563e17afba3f.1702228319.git.christophe.jaillet@wanadoo.fr>



On 12/10/23 10:13, Christophe JAILLET wrote:
> ida_alloc() and ida_free() should be preferred to the deprecated
> ida_simple_get() and ida_simple_remove().
> 
> This is less verbose.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/nvdimm/btt_devs.c       | 6 +++---
>  drivers/nvdimm/bus.c            | 4 ++--
>  drivers/nvdimm/dax_devs.c       | 4 ++--
>  drivers/nvdimm/dimm_devs.c      | 4 ++--
>  drivers/nvdimm/namespace_devs.c | 7 +++----
>  drivers/nvdimm/pfn_devs.c       | 4 ++--
>  6 files changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
> index fabbb31f2c35..497fd434a6a1 100644
> --- a/drivers/nvdimm/btt_devs.c
> +++ b/drivers/nvdimm/btt_devs.c
> @@ -19,7 +19,7 @@ static void nd_btt_release(struct device *dev)
>  
>  	dev_dbg(dev, "trace\n");
>  	nd_detach_ndns(&nd_btt->dev, &nd_btt->ndns);
> -	ida_simple_remove(&nd_region->btt_ida, nd_btt->id);
> +	ida_free(&nd_region->btt_ida, nd_btt->id);
>  	kfree(nd_btt->uuid);
>  	kfree(nd_btt);
>  }
> @@ -191,7 +191,7 @@ static struct device *__nd_btt_create(struct nd_region *nd_region,
>  	if (!nd_btt)
>  		return NULL;
>  
> -	nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL);
> +	nd_btt->id = ida_alloc(&nd_region->btt_ida, GFP_KERNEL);
>  	if (nd_btt->id < 0)
>  		goto out_nd_btt;
>  
> @@ -217,7 +217,7 @@ static struct device *__nd_btt_create(struct nd_region *nd_region,
>  	return dev;
>  
>  out_put_id:
> -	ida_simple_remove(&nd_region->btt_ida, nd_btt->id);
> +	ida_free(&nd_region->btt_ida, nd_btt->id);
>  
>  out_nd_btt:
>  	kfree(nd_btt);
> diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
> index 5852fe290523..ef3d0f83318b 100644
> --- a/drivers/nvdimm/bus.c
> +++ b/drivers/nvdimm/bus.c
> @@ -285,7 +285,7 @@ static void nvdimm_bus_release(struct device *dev)
>  	struct nvdimm_bus *nvdimm_bus;
>  
>  	nvdimm_bus = container_of(dev, struct nvdimm_bus, dev);
> -	ida_simple_remove(&nd_ida, nvdimm_bus->id);
> +	ida_free(&nd_ida, nvdimm_bus->id);
>  	kfree(nvdimm_bus);
>  }
>  
> @@ -342,7 +342,7 @@ struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
>  	INIT_LIST_HEAD(&nvdimm_bus->list);
>  	INIT_LIST_HEAD(&nvdimm_bus->mapping_list);
>  	init_waitqueue_head(&nvdimm_bus->wait);
> -	nvdimm_bus->id = ida_simple_get(&nd_ida, 0, 0, GFP_KERNEL);
> +	nvdimm_bus->id = ida_alloc(&nd_ida, GFP_KERNEL);
>  	if (nvdimm_bus->id < 0) {
>  		kfree(nvdimm_bus);
>  		return NULL;
> diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c
> index 3bd61f245788..6b4922de3047 100644
> --- a/drivers/nvdimm/dax_devs.c
> +++ b/drivers/nvdimm/dax_devs.c
> @@ -18,7 +18,7 @@ static void nd_dax_release(struct device *dev)
>  
>  	dev_dbg(dev, "trace\n");
>  	nd_detach_ndns(dev, &nd_pfn->ndns);
> -	ida_simple_remove(&nd_region->dax_ida, nd_pfn->id);
> +	ida_free(&nd_region->dax_ida, nd_pfn->id);
>  	kfree(nd_pfn->uuid);
>  	kfree(nd_dax);
>  }
> @@ -55,7 +55,7 @@ static struct nd_dax *nd_dax_alloc(struct nd_region *nd_region)
>  		return NULL;
>  
>  	nd_pfn = &nd_dax->nd_pfn;
> -	nd_pfn->id = ida_simple_get(&nd_region->dax_ida, 0, 0, GFP_KERNEL);
> +	nd_pfn->id = ida_alloc(&nd_region->dax_ida, GFP_KERNEL);
>  	if (nd_pfn->id < 0) {
>  		kfree(nd_dax);
>  		return NULL;
> diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
> index 1273873582be..3ceddae0509f 100644
> --- a/drivers/nvdimm/dimm_devs.c
> +++ b/drivers/nvdimm/dimm_devs.c
> @@ -194,7 +194,7 @@ static void nvdimm_release(struct device *dev)
>  {
>  	struct nvdimm *nvdimm = to_nvdimm(dev);
>  
> -	ida_simple_remove(&dimm_ida, nvdimm->id);
> +	ida_free(&dimm_ida, nvdimm->id);
>  	kfree(nvdimm);
>  }
>  
> @@ -592,7 +592,7 @@ struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,
>  	if (!nvdimm)
>  		return NULL;
>  
> -	nvdimm->id = ida_simple_get(&dimm_ida, 0, 0, GFP_KERNEL);
> +	nvdimm->id = ida_alloc(&dimm_ida, GFP_KERNEL);
>  	if (nvdimm->id < 0) {
>  		kfree(nvdimm);
>  		return NULL;
> diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
> index 07177eadc56e..fa1202e848d9 100644
> --- a/drivers/nvdimm/namespace_devs.c
> +++ b/drivers/nvdimm/namespace_devs.c
> @@ -27,7 +27,7 @@ static void namespace_pmem_release(struct device *dev)
>  	struct nd_region *nd_region = to_nd_region(dev->parent);
>  
>  	if (nspm->id >= 0)
> -		ida_simple_remove(&nd_region->ns_ida, nspm->id);
> +		ida_free(&nd_region->ns_ida, nspm->id);
>  	kfree(nspm->alt_name);
>  	kfree(nspm->uuid);
>  	kfree(nspm);
> @@ -1810,7 +1810,7 @@ static struct device *nd_namespace_pmem_create(struct nd_region *nd_region)
>  	res->name = dev_name(&nd_region->dev);
>  	res->flags = IORESOURCE_MEM;
>  
> -	nspm->id = ida_simple_get(&nd_region->ns_ida, 0, 0, GFP_KERNEL);
> +	nspm->id = ida_alloc(&nd_region->ns_ida, GFP_KERNEL);
>  	if (nspm->id < 0) {
>  		kfree(nspm);
>  		return NULL;
> @@ -2188,8 +2188,7 @@ int nd_region_register_namespaces(struct nd_region *nd_region, int *err)
>  			struct nd_namespace_pmem *nspm;
>  
>  			nspm = to_nd_namespace_pmem(dev);
> -			id = ida_simple_get(&nd_region->ns_ida, 0, 0,
> -					    GFP_KERNEL);
> +			id = ida_alloc(&nd_region->ns_ida, GFP_KERNEL);
>  			nspm->id = id;
>  		} else
>  			id = i;
> diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
> index 0d08e21a1cea..586348125b61 100644
> --- a/drivers/nvdimm/pfn_devs.c
> +++ b/drivers/nvdimm/pfn_devs.c
> @@ -22,7 +22,7 @@ static void nd_pfn_release(struct device *dev)
>  
>  	dev_dbg(dev, "trace\n");
>  	nd_detach_ndns(&nd_pfn->dev, &nd_pfn->ndns);
> -	ida_simple_remove(&nd_region->pfn_ida, nd_pfn->id);
> +	ida_free(&nd_region->pfn_ida, nd_pfn->id);
>  	kfree(nd_pfn->uuid);
>  	kfree(nd_pfn);
>  }
> @@ -326,7 +326,7 @@ static struct nd_pfn *nd_pfn_alloc(struct nd_region *nd_region)
>  	if (!nd_pfn)
>  		return NULL;
>  
> -	nd_pfn->id = ida_simple_get(&nd_region->pfn_ida, 0, 0, GFP_KERNEL);
> +	nd_pfn->id = ida_alloc(&nd_region->pfn_ida, GFP_KERNEL);
>  	if (nd_pfn->id < 0) {
>  		kfree(nd_pfn);
>  		return NULL;

      reply	other threads:[~2023-12-12  1:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-10 17:13 [PATCH] nvdimm: Remove usage of the deprecated ida_simple_xx() API Christophe JAILLET
2023-12-12  1:26 ` Dave Jiang [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=60c10003-083e-4025-98a3-78e78701043d@intel.com \
    --to=dave.jiang@intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=vishal.l.verma@intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).