linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ti-adc128s052: Fix number of channels when device tree is used
@ 2022-06-30 23:01 Nishanth Menon
  2022-07-01  3:38 ` Nishanth Menon
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nishanth Menon @ 2022-06-30 23:01 UTC (permalink / raw)
  To: Javier Martinez Canillas, Nishanth Menon, Nuno Sá,
	Christophe JAILLET, Alexandru Ardelean, Lars-Peter Clausen,
	Jonathan Cameron
  Cc: linux-kernel, linux-iio, stable

When device_match_data is called - with device tree, of_match list is
looked up to find the data, which by default is 0. So, no matter which
kind of device compatible we use, we match with config 0 which implies
we enable 8 channels even on devices that do not have 8 channels.

Solve it by providing the match data similar to what we do with the ACPI
lookup information.

Fixes: 9e611c9e5a20 ("iio: adc128s052: Add OF match table")
Cc: <stable@vger.kernel.org> # 5.0+
Signed-off-by: Nishanth Menon <nm@ti.com>
---

Side note: commits 9e611c9e5a20c ("iio: adc128s052: Add OF match table"),
37cd3c8768edc ("iio: adc128s052: Add pin-compatible IDs"),
b41fa86b67bd3 ("iio:adc128s052: add support for adc124s021") introduce
code that is fixed by this patch, but it makes no real sense to go and
split this patch to apply to versions older than 5.0 - which seems to be
the earliest the patch would apply. I picked the "Add OF match table" as
the patch that set the precedence which follow on patches followed.

 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..21a7764cbb93 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 = 0},
+	{ .compatible = "ti,adc122s021", .data = 1},
+	{ .compatible = "ti,adc122s051", .data = 1},
+	{ .compatible = "ti,adc122s101", .data = 1},
+	{ .compatible = "ti,adc124s021", .data = 2},
+	{ .compatible = "ti,adc124s051", .data = 2},
+	{ .compatible = "ti,adc124s101", .data = 2},
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, adc128_of_match);
-- 
2.31.1


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

end of thread, other threads:[~2022-07-05 17:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 23:01 [PATCH] iio: adc: ti-adc128s052: Fix number of channels when device tree is used Nishanth Menon
2022-07-01  3:38 ` Nishanth Menon
2022-07-01 10:08   ` Andy Shevchenko
2022-07-01 10:13 ` Andy Shevchenko
2022-07-01 16:31   ` Jonathan Cameron
2022-07-05 17:47 ` kernel test robot

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