mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: adc: qcom-spmi-adc5-gen3: Reuse IIO device ID for ADC_TM auxiliary device
@ 2026-10-28 14:09 Loic Poulain
  2026-11-01  2:00 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Loic Poulain @ 2026-10-28 14:09 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-arm-msm, linux-iio, linux-kernel, Loic Poulain

A recent fix in ADC5 Gen3 driver allocates a dedicated auxiliary-device
ID through an IDA to ensure that ADC_TM auxiliary devices receive unique
names on the auxiliary bus.

However, each ADC instance is already assigned a unique IIO device ID.
Reuse that existing identifier when registering the ADC_TM auxiliary
device instead of maintaining a separate IDA solely for auxiliary device
naming.

This removes the custom ID allocation and release handling while
preserving unique auxiliary device names across multiple ADC instances.

Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
---
 drivers/iio/adc/qcom-spmi-adc5-gen3.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
index f0b2544c16322374644ac3a2eda63322f318e25f..a23eb5c9096d765af7d76ad66b50ed895782b256 100644
--- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c
+++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
@@ -15,7 +15,6 @@
 #include <linux/dev_printk.h>
 #include <linux/err.h>
 #include <linux/export.h>
-#include <linux/idr.h>
 #include <linux/iio/adc/qcom-adc5-gen3-common.h>
 #include <linux/iio/iio.h>
 #include <linux/interrupt.h>
@@ -609,16 +608,9 @@ static void adc5_gen3_delete_aux(void *data)
 	auxiliary_device_delete(data);
 }
 
-static DEFINE_IDA(adc5_gen3_aux_ida);
+static void adc5_gen3_aux_device_release(struct device *dev) {}
 
-static void adc5_gen3_aux_device_release(struct device *dev)
-{
-	struct auxiliary_device *adev = to_auxiliary_dev(dev);
-
-	ida_free(&adc5_gen3_aux_ida, adev->id);
-}
-
-static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
+static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc, int id)
 {
 	struct tm5_aux_dev_wrapper *aux_device;
 	int i, ret, i_tm = 0;
@@ -628,6 +620,7 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
 		return -ENOMEM;
 
 	aux_device->aux_dev.name = "adc5_tm_gen3";
+	aux_device->aux_dev.id = id;
 	aux_device->aux_dev.dev.parent = adc->dev;
 	aux_device->aux_dev.dev.release = adc5_gen3_aux_device_release;
 
@@ -650,16 +643,9 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
 
 	aux_device->n_tm_channels = adc->n_tm_channels;
 
-	ret = ida_alloc(&adc5_gen3_aux_ida, GFP_KERNEL);
-	if (ret < 0)
-		return ret;
-	aux_device->aux_dev.id = ret;
-
 	ret = auxiliary_device_init(&aux_device->aux_dev);
-	if (ret) {
-		ida_free(&adc5_gen3_aux_ida, aux_device->aux_dev.id);
+	if (ret)
 		return ret;
-	}
 
 	ret = devm_add_action_or_reset(adc->dev, adc5_gen3_uninit_aux,
 				       &aux_device->aux_dev);
@@ -814,7 +800,7 @@ static int adc5_gen3_probe(struct platform_device *pdev)
 		return ret;
 
 	if (adc->n_tm_channels > 0) {
-		ret = adc5_gen3_add_aux_tm_device(adc);
+		ret = adc5_gen3_add_aux_tm_device(adc, iio_device_id(indio_dev));
 		if (ret)
 			dev_err_probe(dev, ret,
 				      "Failed to add auxiliary TM device\n");

---
base-commit: f1ac44c32cba88ad65dcecd4a279661d14e93651
change-id: 20261028-fix-adc5-tm-c96b13a4f442

Best regards,
-- 
Loic Poulain <loic.poulain@oss.qualcomm.com>


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

* Re: [PATCH] iio: adc: qcom-spmi-adc5-gen3: Reuse IIO device ID for ADC_TM auxiliary device
  2026-10-28 14:09 [PATCH] iio: adc: qcom-spmi-adc5-gen3: Reuse IIO device ID for ADC_TM auxiliary device Loic Poulain
@ 2026-11-01  2:00 ` Jonathan Cameron
  2026-11-01  3:15   ` Shawn Guo
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2026-11-01  2:00 UTC (permalink / raw)
  To: Loic Poulain
  Cc: David Lechner, Nuno Sá,
	Andy Shevchenko, linux-arm-msm, linux-iio, linux-kernel,
	Shawn Guo

On Wed, 28 Oct 2026 15:09:47 +0100
Loic Poulain <loic.poulain@oss.qualcomm.com> wrote:

Hi Loic,

> A recent fix in ADC5 Gen3 driver allocates a dedicated auxiliary-device
> ID through an IDA to ensure that ADC_TM auxiliary devices receive unique
> names on the auxiliary bus.
When talking about another patch I'd refer to it by name and ideally
also add a Link tag to the lore.kernel.org for it to the tags block.
I think you mean:

iio: adc: qcom-spmi-adc5-gen3: Allocate unique ADC_TM aux device IDs
Link: https://lore.kernel.org/all/20261008031154.3440632-1-shengchao.guo@oss.qualcomm.com/

> 
> However, each ADC instance is already assigned a unique IIO device ID.
> Reuse that existing identifier when registering the ADC_TM auxiliary
> device instead of maintaining a separate IDA solely for auxiliary device
> naming.
> 
> This removes the custom ID allocation and release handling while
> preserving unique auxiliary device names across multiple ADC instances.

> 
> Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>


The fix hasn't gone upstream yet (assuming it is the patch I think
it is!).  Would it be better to just squash this onto that patch
and avoid having to care about a version of the intermediate code?

+CC Shawn. 

Thanks,

Jonathan

> ---
>  drivers/iio/adc/qcom-spmi-adc5-gen3.c | 24 +++++-------------------
>  1 file changed, 5 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
> index f0b2544c16322374644ac3a2eda63322f318e25f..a23eb5c9096d765af7d76ad66b50ed895782b256 100644
> --- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c
> +++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
> @@ -15,7 +15,6 @@
>  #include <linux/dev_printk.h>
>  #include <linux/err.h>
>  #include <linux/export.h>
> -#include <linux/idr.h>
>  #include <linux/iio/adc/qcom-adc5-gen3-common.h>
>  #include <linux/iio/iio.h>
>  #include <linux/interrupt.h>
> @@ -609,16 +608,9 @@ static void adc5_gen3_delete_aux(void *data)
>  	auxiliary_device_delete(data);
>  }
>  
> -static DEFINE_IDA(adc5_gen3_aux_ida);
> +static void adc5_gen3_aux_device_release(struct device *dev) {}
>  
> -static void adc5_gen3_aux_device_release(struct device *dev)
> -{
> -	struct auxiliary_device *adev = to_auxiliary_dev(dev);
> -
> -	ida_free(&adc5_gen3_aux_ida, adev->id);n
> -}
> -
> -static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
> +static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc, int id)
>  {
>  	struct tm5_aux_dev_wrapper *aux_device;
>  	int i, ret, i_tm = 0;
> @@ -628,6 +620,7 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
>  		return -ENOMEM;
>  
>  	aux_device->aux_dev.name = "adc5_tm_gen3";
> +	aux_device->aux_dev.id = id;
>  	aux_device->aux_dev.dev.parent = adc->dev;
>  	aux_device->aux_dev.dev.release = adc5_gen3_aux_device_release;
>  
> @@ -650,16 +643,9 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
>  
>  	aux_device->n_tm_channels = adc->n_tm_channels;
>  
> -	ret = ida_alloc(&adc5_gen3_aux_ida, GFP_KERNEL);
> -	if (ret < 0)
> -		return ret;
> -	aux_device->aux_dev.id = ret;
> -
>  	ret = auxiliary_device_init(&aux_device->aux_dev);
> -	if (ret) {
> -		ida_free(&adc5_gen3_aux_ida, aux_device->aux_dev.id);
> +	if (ret)
>  		return ret;
> -	}
>  
>  	ret = devm_add_action_or_reset(adc->dev, adc5_gen3_uninit_aux,
>  				       &aux_device->aux_dev);
> @@ -814,7 +800,7 @@ static int adc5_gen3_probe(struct platform_device *pdev)
>  		return ret;
>  
>  	if (adc->n_tm_channels > 0) {
> -		ret = adc5_gen3_add_aux_tm_device(adc);
> +		ret = adc5_gen3_add_aux_tm_device(adc, iio_device_id(indio_dev));
>  		if (ret)
>  			dev_err_probe(dev, ret,
>  				      "Failed to add auxiliary TM device\n");
> 
> ---
> base-commit: f1ac44c32cba88ad65dcecd4a279661d14e93651
> change-id: 20261028-fix-adc5-tm-c96b13a4f442
> 
> Best regards,


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

* Re: [PATCH] iio: adc: qcom-spmi-adc5-gen3: Reuse IIO device ID for ADC_TM auxiliary device
  2026-11-01  2:00 ` Jonathan Cameron
@ 2026-11-01  3:15   ` Shawn Guo
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2026-11-01  3:15 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Loic Poulain, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-arm-msm, linux-iio, linux-kernel

On Sun, Nov 01, 2026 at 02:00:47AM +0000, Jonathan Cameron wrote:
> On Wed, 28 Oct 2026 15:09:47 +0100
> Loic Poulain <loic.poulain@oss.qualcomm.com> wrote:
> 
> Hi Loic,
> 
> > A recent fix in ADC5 Gen3 driver allocates a dedicated auxiliary-device
> > ID through an IDA to ensure that ADC_TM auxiliary devices receive unique
> > names on the auxiliary bus.
> When talking about another patch I'd refer to it by name and ideally
> also add a Link tag to the lore.kernel.org for it to the tags block.
> I think you mean:
> 
> iio: adc: qcom-spmi-adc5-gen3: Allocate unique ADC_TM aux device IDs
> Link: https://lore.kernel.org/all/20261008031154.3440632-1-shengchao.guo@oss.qualcomm.com/
> 
> > 
> > However, each ADC instance is already assigned a unique IIO device ID.
> > Reuse that existing identifier when registering the ADC_TM auxiliary
> > device instead of maintaining a separate IDA solely for auxiliary device
> > naming.
> > 
> > This removes the custom ID allocation and release handling while
> > preserving unique auxiliary device names across multiple ADC instances.
> 
> > 
> > Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
> 
> 
> The fix hasn't gone upstream yet (assuming it is the patch I think
> it is!).  Would it be better to just squash this onto that patch
> and avoid having to care about a version of the intermediate code?
> 
> +CC Shawn. 

Thanks for looping me, Jonathan!

I agree with you on the squashing. I just sent you the squashed version
(with Loic being author) [1], so that you can just replace the one in
your queue.

Shawn

[1] https://lore.kernel.org/all/20261101030902.1387122-1-shengchao.guo@oss.qualcomm.com/

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

end of thread, other threads:[~2026-11-01  3:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28 14:09 [PATCH] iio: adc: qcom-spmi-adc5-gen3: Reuse IIO device ID for ADC_TM auxiliary device Loic Poulain
2026-11-01  2:00 ` Jonathan Cameron
2026-11-01  3:15   ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®