linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc128s052: add proper .data members in adc128_of_match table
@ 2022-11-15 13:23 Rasmus Villemoes
  2022-11-15 13:35 ` Andy Shevchenko
  2022-11-22 14:41 ` Rasmus Villemoes
  0 siblings, 2 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2022-11-15 13:23 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Javier Arteaga,
	Dan O'Donovan, Andy Shevchenko, Nicola Lunghi
  Cc: Rasmus Villemoes, Jonathan Cameron, linux-iio, linux-kernel

Prior to commit bd5d54e4d49d ("iio: adc128s052: add ACPI _HID
AANT1280"), the driver unconditionally used spi_get_device_id() to get
the index into the adc128_config array.

However, with that commit, OF-based boards now incorrectly treat all
supported sensors as if they are an adc128s052, because all the .data
members of the adc128_of_match table are implicitly 0. Our board,
which has an adc122s021, thus exposes 8 channels whereas it really
only has two.

Fixes: bd5d54e4d49d ("iio: adc128s052: add ACPI _HID AANT1280")
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---

I think the driver could be simplified somewhat by having just one
single adc_channels[] array with the 8 entries, unconditionally use
that as ->channels, with ->num_channels being taken from the match
data instead of having this indirection through the auxiliary config
array.

But this patch is properly more suited for -stable.

 drivers/iio/adc/ti-adc128s052.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index 622fd384983c..b3d5b9b7255b 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -181,13 +181,13 @@ static int adc128_probe(struct spi_device *spi)
 }
 
 static const struct of_device_id adc128_of_match[] = {
-	{ .compatible = "ti,adc128s052", },
-	{ .compatible = "ti,adc122s021", },
-	{ .compatible = "ti,adc122s051", },
-	{ .compatible = "ti,adc122s101", },
-	{ .compatible = "ti,adc124s021", },
-	{ .compatible = "ti,adc124s051", },
-	{ .compatible = "ti,adc124s101", },
+	{ .compatible = "ti,adc128s052", .data = (void*)0L, },
+	{ .compatible = "ti,adc122s021", .data = (void*)1L, },
+	{ .compatible = "ti,adc122s051", .data = (void*)1L, },
+	{ .compatible = "ti,adc122s101", .data = (void*)1L, },
+	{ .compatible = "ti,adc124s021", .data = (void*)2L, },
+	{ .compatible = "ti,adc124s051", .data = (void*)2L, },
+	{ .compatible = "ti,adc124s101", .data = (void*)2L, },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, adc128_of_match);
-- 
2.37.2


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

* Re: [PATCH] iio: adc128s052: add proper .data members in adc128_of_match table
  2022-11-15 13:23 [PATCH] iio: adc128s052: add proper .data members in adc128_of_match table Rasmus Villemoes
@ 2022-11-15 13:35 ` Andy Shevchenko
  2022-11-22 14:41 ` Rasmus Villemoes
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-11-15 13:35 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Jonathan Cameron, Lars-Peter Clausen, Javier Arteaga,
	Dan O'Donovan, Nicola Lunghi, Jonathan Cameron, linux-iio,
	linux-kernel

On Tue, Nov 15, 2022 at 02:23:23PM +0100, Rasmus Villemoes wrote:
> Prior to commit bd5d54e4d49d ("iio: adc128s052: add ACPI _HID
> AANT1280"), the driver unconditionally used spi_get_device_id() to get
> the index into the adc128_config array.
> 
> However, with that commit, OF-based boards now incorrectly treat all
> supported sensors as if they are an adc128s052, because all the .data
> members of the adc128_of_match table are implicitly 0. Our board,
> which has an adc122s021, thus exposes 8 channels whereas it really
> only has two.
> 
> Fixes: bd5d54e4d49d ("iio: adc128s052: add ACPI _HID AANT1280")
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> 
> I think the driver could be simplified somewhat by having just one
> single adc_channels[] array with the 8 entries, unconditionally use
> that as ->channels, with ->num_channels being taken from the match
> data instead of having this indirection through the auxiliary config
> array.

Hmm... I have a patch locally that changes this to take pointers instead of
numbers and using spi_get_device_match_data() (but the latter is only available
in Linux Next so far).

> But this patch is properly more suited for -stable.

LGTM for time being
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

>  drivers/iio/adc/ti-adc128s052.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
> index 622fd384983c..b3d5b9b7255b 100644
> --- a/drivers/iio/adc/ti-adc128s052.c
> +++ b/drivers/iio/adc/ti-adc128s052.c
> @@ -181,13 +181,13 @@ static int adc128_probe(struct spi_device *spi)
>  }
>  
>  static const struct of_device_id adc128_of_match[] = {
> -	{ .compatible = "ti,adc128s052", },
> -	{ .compatible = "ti,adc122s021", },
> -	{ .compatible = "ti,adc122s051", },
> -	{ .compatible = "ti,adc122s101", },
> -	{ .compatible = "ti,adc124s021", },
> -	{ .compatible = "ti,adc124s051", },
> -	{ .compatible = "ti,adc124s101", },
> +	{ .compatible = "ti,adc128s052", .data = (void*)0L, },
> +	{ .compatible = "ti,adc122s021", .data = (void*)1L, },
> +	{ .compatible = "ti,adc122s051", .data = (void*)1L, },
> +	{ .compatible = "ti,adc122s101", .data = (void*)1L, },
> +	{ .compatible = "ti,adc124s021", .data = (void*)2L, },
> +	{ .compatible = "ti,adc124s051", .data = (void*)2L, },
> +	{ .compatible = "ti,adc124s101", .data = (void*)2L, },
>  	{ /* sentinel */ },
>  };
>  MODULE_DEVICE_TABLE(of, adc128_of_match);
> -- 
> 2.37.2
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] iio: adc128s052: add proper .data members in adc128_of_match table
  2022-11-15 13:23 [PATCH] iio: adc128s052: add proper .data members in adc128_of_match table Rasmus Villemoes
  2022-11-15 13:35 ` Andy Shevchenko
@ 2022-11-22 14:41 ` Rasmus Villemoes
  2022-11-23 21:00   ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Rasmus Villemoes @ 2022-11-22 14:41 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Javier Arteaga,
	Dan O'Donovan, Andy Shevchenko, Nicola Lunghi
  Cc: Jonathan Cameron, linux-iio, linux-kernel

On 15/11/2022 14.23, Rasmus Villemoes wrote:
> Prior to commit bd5d54e4d49d ("iio: adc128s052: add ACPI _HID
> AANT1280"), the driver unconditionally used spi_get_device_id() to get
> the index into the adc128_config array.
> 
> However, with that commit, OF-based boards now incorrectly treat all
> supported sensors as if they are an adc128s052, because all the .data
> members of the adc128_of_match table are implicitly 0. Our board,
> which has an adc122s021, thus exposes 8 channels whereas it really
> only has two.
> 
> Fixes: bd5d54e4d49d ("iio: adc128s052: add ACPI _HID AANT1280")
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---

Ping. Any chance this could be picked up before the merge window for 6.2
opens?

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

* Re: [PATCH] iio: adc128s052: add proper .data members in adc128_of_match table
  2022-11-22 14:41 ` Rasmus Villemoes
@ 2022-11-23 21:00   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-11-23 21:00 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Lars-Peter Clausen, Javier Arteaga, Dan O'Donovan,
	Andy Shevchenko, Nicola Lunghi, Jonathan Cameron, linux-iio,
	linux-kernel

On Tue, 22 Nov 2022 15:41:21 +0100
Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:

> On 15/11/2022 14.23, Rasmus Villemoes wrote:
> > Prior to commit bd5d54e4d49d ("iio: adc128s052: add ACPI _HID
> > AANT1280"), the driver unconditionally used spi_get_device_id() to get
> > the index into the adc128_config array.
> > 
> > However, with that commit, OF-based boards now incorrectly treat all
> > supported sensors as if they are an adc128s052, because all the .data
> > members of the adc128_of_match table are implicitly 0. Our board,
> > which has an adc122s021, thus exposes 8 channels whereas it really
> > only has two.
> > 
> > Fixes: bd5d54e4d49d ("iio: adc128s052: add ACPI _HID AANT1280")
> > Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> > ---  
> 
> Ping. Any chance this could be picked up before the merge window for 6.2
> opens?

Given it is a clear fix, but for an issue that is multiple versions old
(so I'm not sneaking it in post rc6)..
No actual rush on this, but meh I'm queuing a bunch of other stuff that
will hopefully just make it this cycle so applied to the togreg branch of iio.git
and marked for stable.

Thanks,

Jonathan

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

end of thread, other threads:[~2022-11-23 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-15 13:23 [PATCH] iio: adc128s052: add proper .data members in adc128_of_match table Rasmus Villemoes
2022-11-15 13:35 ` Andy Shevchenko
2022-11-22 14:41 ` Rasmus Villemoes
2022-11-23 21:00   ` Jonathan Cameron

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).