linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drivers: pci: Directly use ida_alloc()/free()
@ 2022-06-02  7:11 Ke Liu
  2022-06-08 18:42 ` Bjorn Helgaas
  2022-06-09 17:31 ` Bjorn Helgaas
  0 siblings, 2 replies; 4+ messages in thread
From: Ke Liu @ 2022-06-02  7:11 UTC (permalink / raw)
  To: bhelgaas
  Cc: nirmal.patel, jonathan.derrick, lpieralisi, robh, kw,
	kurt.schwemmer, logang, linux-pci, linux-kernel, Ke Liu

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

Signed-off-by: Ke Liu <liuke94@huawei.com>
---
v2	fix sign-off name suggest by Bjorn Helgaas
---
 drivers/pci/controller/vmd.c   | 6 +++---
 drivers/pci/switch/switchtec.c | 7 +++----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index 94a14a3d7e55..49c72c2d8fe7 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -894,7 +894,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
 		return -ENOMEM;
 
 	vmd->dev = dev;
-	vmd->instance = ida_simple_get(&vmd_instance_ida, 0, 0, GFP_KERNEL);
+	vmd->instance = ida_alloc(&vmd_instance_ida, GFP_KERNEL);
 	if (vmd->instance < 0)
 		return vmd->instance;
 
@@ -935,7 +935,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	return 0;
 
  out_release_instance:
-	ida_simple_remove(&vmd_instance_ida, vmd->instance);
+	ida_free(&vmd_instance_ida, vmd->instance);
 	kfree(vmd->name);
 	return err;
 }
@@ -958,7 +958,7 @@ static void vmd_remove(struct pci_dev *dev)
 	vmd_cleanup_srcu(vmd);
 	vmd_detach_resources(vmd);
 	vmd_remove_irq_domain(vmd);
-	ida_simple_remove(&vmd_instance_ida, vmd->instance);
+	ida_free(&vmd_instance_ida, vmd->instance);
 	kfree(vmd->name);
 }
 
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index c36c1238c604..75be4fe22509 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -1376,8 +1376,7 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev)
 	dev->groups = switchtec_device_groups;
 	dev->release = stdev_release;
 
-	minor = ida_simple_get(&switchtec_minor_ida, 0, 0,
-			       GFP_KERNEL);
+	minor = ida_alloc(&switchtec_minor_ida, GFP_KERNEL);
 	if (minor < 0) {
 		rc = minor;
 		goto err_put;
@@ -1692,7 +1691,7 @@ static int switchtec_pci_probe(struct pci_dev *pdev,
 err_devadd:
 	stdev_kill(stdev);
 err_put:
-	ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
+	ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt));
 	put_device(&stdev->dev);
 	return rc;
 }
@@ -1704,7 +1703,7 @@ static void switchtec_pci_remove(struct pci_dev *pdev)
 	pci_set_drvdata(pdev, NULL);
 
 	cdev_device_del(&stdev->cdev, &stdev->dev);
-	ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
+	ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt));
 	dev_info(&stdev->dev, "unregistered.\n");
 	stdev_kill(stdev);
 	put_device(&stdev->dev);
-- 
2.25.1


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

* Re: [PATCH v2] drivers: pci: Directly use ida_alloc()/free()
  2022-06-02  7:11 [PATCH v2] drivers: pci: Directly use ida_alloc()/free() Ke Liu
@ 2022-06-08 18:42 ` Bjorn Helgaas
  2022-06-08 19:28   ` Logan Gunthorpe
  2022-06-09 17:31 ` Bjorn Helgaas
  1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2022-06-08 18:42 UTC (permalink / raw)
  To: Ke Liu
  Cc: bhelgaas, nirmal.patel, jonathan.derrick, lpieralisi, robh, kw,
	kurt.schwemmer, logang, linux-pci, linux-kernel

On Thu, Jun 02, 2022 at 07:11:15AM +0000, Ke Liu wrote:
> Use ida_alloc()/ida_free() instead of deprecated
> ida_simple_get()/ida_simple_remove().
> 
> Signed-off-by: Ke Liu <liuke94@huawei.com>

I'd like acks from a vmd maintainer (Nirmal) and a switchtec
maintainer (Kirt, Logan) before applying this.

You don't need to post this again with those acks, but if you do post
it again for some reason, take note of the subject line history; see
"git log --oneline drivers/pci/controller/ drivers/pci/switch/"

> ---
> v2	fix sign-off name suggest by Bjorn Helgaas
> ---
>  drivers/pci/controller/vmd.c   | 6 +++---
>  drivers/pci/switch/switchtec.c | 7 +++----
>  2 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
> index 94a14a3d7e55..49c72c2d8fe7 100644
> --- a/drivers/pci/controller/vmd.c
> +++ b/drivers/pci/controller/vmd.c
> @@ -894,7 +894,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  		return -ENOMEM;
>  
>  	vmd->dev = dev;
> -	vmd->instance = ida_simple_get(&vmd_instance_ida, 0, 0, GFP_KERNEL);
> +	vmd->instance = ida_alloc(&vmd_instance_ida, GFP_KERNEL);
>  	if (vmd->instance < 0)
>  		return vmd->instance;
>  
> @@ -935,7 +935,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	return 0;
>  
>   out_release_instance:
> -	ida_simple_remove(&vmd_instance_ida, vmd->instance);
> +	ida_free(&vmd_instance_ida, vmd->instance);
>  	kfree(vmd->name);
>  	return err;
>  }
> @@ -958,7 +958,7 @@ static void vmd_remove(struct pci_dev *dev)
>  	vmd_cleanup_srcu(vmd);
>  	vmd_detach_resources(vmd);
>  	vmd_remove_irq_domain(vmd);
> -	ida_simple_remove(&vmd_instance_ida, vmd->instance);
> +	ida_free(&vmd_instance_ida, vmd->instance);
>  	kfree(vmd->name);
>  }
>  
> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> index c36c1238c604..75be4fe22509 100644
> --- a/drivers/pci/switch/switchtec.c
> +++ b/drivers/pci/switch/switchtec.c
> @@ -1376,8 +1376,7 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev)
>  	dev->groups = switchtec_device_groups;
>  	dev->release = stdev_release;
>  
> -	minor = ida_simple_get(&switchtec_minor_ida, 0, 0,
> -			       GFP_KERNEL);
> +	minor = ida_alloc(&switchtec_minor_ida, GFP_KERNEL);
>  	if (minor < 0) {
>  		rc = minor;
>  		goto err_put;
> @@ -1692,7 +1691,7 @@ static int switchtec_pci_probe(struct pci_dev *pdev,
>  err_devadd:
>  	stdev_kill(stdev);
>  err_put:
> -	ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
> +	ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt));
>  	put_device(&stdev->dev);
>  	return rc;
>  }
> @@ -1704,7 +1703,7 @@ static void switchtec_pci_remove(struct pci_dev *pdev)
>  	pci_set_drvdata(pdev, NULL);
>  
>  	cdev_device_del(&stdev->cdev, &stdev->dev);
> -	ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
> +	ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt));
>  	dev_info(&stdev->dev, "unregistered.\n");
>  	stdev_kill(stdev);
>  	put_device(&stdev->dev);
> -- 
> 2.25.1
> 

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

* Re: [PATCH v2] drivers: pci: Directly use ida_alloc()/free()
  2022-06-08 18:42 ` Bjorn Helgaas
@ 2022-06-08 19:28   ` Logan Gunthorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2022-06-08 19:28 UTC (permalink / raw)
  To: Bjorn Helgaas, Ke Liu
  Cc: bhelgaas, nirmal.patel, jonathan.derrick, lpieralisi, robh, kw,
	kurt.schwemmer, linux-pci, linux-kernel



On 2022-06-08 12:42, Bjorn Helgaas wrote:
> On Thu, Jun 02, 2022 at 07:11:15AM +0000, Ke Liu wrote:
>> Use ida_alloc()/ida_free() instead of deprecated
>> ida_simple_get()/ida_simple_remove().
>>
>> Signed-off-by: Ke Liu <liuke94@huawei.com>
> 
> I'd like acks from a vmd maintainer (Nirmal) and a switchtec
> maintainer (Kirt, Logan) before applying this.
> 
> You don't need to post this again with those acks, but if you do post
> it again for some reason, take note of the subject line history; see
> "git log --oneline drivers/pci/controller/ drivers/pci/switch/"
>> ---
>> v2	fix sign-off name suggest by Bjorn Helgaas
>> ---
>>  drivers/pci/controller/vmd.c   | 6 +++---
>>  drivers/pci/switch/switchtec.c | 7 +++----
>>  2 files changed, 6 insertions(+), 7 deletions(-)


Oh, yup, looks good to me. Thanks!

Acked-by: Logan Gunthorpe <logang@deltatee.com>

Logan

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

* Re: [PATCH v2] drivers: pci: Directly use ida_alloc()/free()
  2022-06-02  7:11 [PATCH v2] drivers: pci: Directly use ida_alloc()/free() Ke Liu
  2022-06-08 18:42 ` Bjorn Helgaas
@ 2022-06-09 17:31 ` Bjorn Helgaas
  1 sibling, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2022-06-09 17:31 UTC (permalink / raw)
  To: Ke Liu
  Cc: bhelgaas, nirmal.patel, jonathan.derrick, lpieralisi, robh, kw,
	kurt.schwemmer, logang, linux-pci, linux-kernel

On Thu, Jun 02, 2022 at 07:11:15AM +0000, Ke Liu wrote:
> Use ida_alloc()/ida_free() instead of deprecated
> ida_simple_get()/ida_simple_remove().
> 
> Signed-off-by: Ke Liu <liuke94@huawei.com>

I split the switchtec part off and applied it with Logan's ack to
pci/ctrl/switchtec for v5.20, thanks!

  PCI: switchtec: Prefer ida_alloc()/free() over ida_simple_get()/remove()

I'll apply the vmd part as soon as one of those folks pipes up.

> ---
> v2	fix sign-off name suggest by Bjorn Helgaas
> ---
>  drivers/pci/controller/vmd.c   | 6 +++---
>  drivers/pci/switch/switchtec.c | 7 +++----
>  2 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
> index 94a14a3d7e55..49c72c2d8fe7 100644
> --- a/drivers/pci/controller/vmd.c
> +++ b/drivers/pci/controller/vmd.c
> @@ -894,7 +894,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  		return -ENOMEM;
>  
>  	vmd->dev = dev;
> -	vmd->instance = ida_simple_get(&vmd_instance_ida, 0, 0, GFP_KERNEL);
> +	vmd->instance = ida_alloc(&vmd_instance_ida, GFP_KERNEL);
>  	if (vmd->instance < 0)
>  		return vmd->instance;
>  
> @@ -935,7 +935,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	return 0;
>  
>   out_release_instance:
> -	ida_simple_remove(&vmd_instance_ida, vmd->instance);
> +	ida_free(&vmd_instance_ida, vmd->instance);
>  	kfree(vmd->name);
>  	return err;
>  }
> @@ -958,7 +958,7 @@ static void vmd_remove(struct pci_dev *dev)
>  	vmd_cleanup_srcu(vmd);
>  	vmd_detach_resources(vmd);
>  	vmd_remove_irq_domain(vmd);
> -	ida_simple_remove(&vmd_instance_ida, vmd->instance);
> +	ida_free(&vmd_instance_ida, vmd->instance);
>  	kfree(vmd->name);
>  }
>  
> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> index c36c1238c604..75be4fe22509 100644
> --- a/drivers/pci/switch/switchtec.c
> +++ b/drivers/pci/switch/switchtec.c
> @@ -1376,8 +1376,7 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev)
>  	dev->groups = switchtec_device_groups;
>  	dev->release = stdev_release;
>  
> -	minor = ida_simple_get(&switchtec_minor_ida, 0, 0,
> -			       GFP_KERNEL);
> +	minor = ida_alloc(&switchtec_minor_ida, GFP_KERNEL);
>  	if (minor < 0) {
>  		rc = minor;
>  		goto err_put;
> @@ -1692,7 +1691,7 @@ static int switchtec_pci_probe(struct pci_dev *pdev,
>  err_devadd:
>  	stdev_kill(stdev);
>  err_put:
> -	ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
> +	ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt));
>  	put_device(&stdev->dev);
>  	return rc;
>  }
> @@ -1704,7 +1703,7 @@ static void switchtec_pci_remove(struct pci_dev *pdev)
>  	pci_set_drvdata(pdev, NULL);
>  
>  	cdev_device_del(&stdev->cdev, &stdev->dev);
> -	ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
> +	ida_free(&switchtec_minor_ida, MINOR(stdev->dev.devt));
>  	dev_info(&stdev->dev, "unregistered.\n");
>  	stdev_kill(stdev);
>  	put_device(&stdev->dev);
> -- 
> 2.25.1
> 

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

end of thread, other threads:[~2022-06-09 17:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  7:11 [PATCH v2] drivers: pci: Directly use ida_alloc()/free() Ke Liu
2022-06-08 18:42 ` Bjorn Helgaas
2022-06-08 19:28   ` Logan Gunthorpe
2022-06-09 17:31 ` Bjorn Helgaas

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 NNTP newsgroup(s).