Skip to contentSkip to conversation

iio: adc: mcp320x: Fix NULL pointer.

PATCH In review Denis Carikli 3 participants 9 messages Jul 22, 2015 – Aug 2, 2015 4 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 iio: adc: mcp320x: Fix NULL pointer.

Without that fix, adc->chip_info is NULL in mcp320x_read_raw

---
 drivers/iio/adc/mcp320x.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/adc/mcp320x.c +1 -0
index 8d9c9b9..fccb2dc 100644
@@ -299,6 +299,7 @@ static int mcp320x_probe(struct spi_device *spi)
 	indio_dev->channels = chip_info->channels;
 	indio_dev->num_channels = chip_info->num_channels;
 
+	adc->chip_info = chip_info;
 	adc->transfer[0].tx_buf = &adc->tx_buf;
 	adc->transfer[0].len = sizeof(adc->tx_buf);
 	adc->transfer[1].rx_buf = adc->rx_buf;
Signature · 1 line
2.4.5

A message that is not in the archive (sent off-list or not yet received): 1437581064-9733-1-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH 2/4 iio: adc: ti-adc128s052: Add adc108s022 ID

---
 drivers/iio/adc/Kconfig         | 6 +++---
 drivers/iio/adc/ti-adc128s052.c | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/iio/adc/Kconfig +3 -3
index 233d47b..ae92f23 100644
@@ -313,11 +313,11 @@ config TI_ADC081C
 	  called ti-adc081c.
 
 config TI_ADC128S052
-	tristate "Texas Instruments ADC128S052/ADC122S021"
+	tristate "Texas Instruments ADC128S052, ADC122S021 and ADC108S022"
 	depends on SPI
 	help
-	  If you say yes here you get support for Texas Instruments ADC128S052
-	  and ADC122S021 chips.
+	  If you say yes here you get support for Texas Instruments ADC128S052,
+	  ADC122S021 and ADC108S022 chips.
 
 	  This driver can also be built as a module. If so, the module will be
 	  called ti-adc128s052.
drivers/iio/adc/ti-adc128s052.c +2 -0
index 915be6b..8aca0ff 100644
@@ -5,6 +5,7 @@
  * Datasheets can be found here:
  * http://www.ti.com/lit/ds/symlink/adc128s052.pdf
  * http://www.ti.com/lit/ds/symlink/adc122s021.pdf
+ * http://www.ti.com/lit/ds/symlink/adc108s022.pdf
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -177,6 +178,7 @@ static int adc128_remove(struct spi_device *spi)
 static const struct spi_device_id adc128_id[] = {
 	{ "adc128s052", 0},	/* index into adc128_config */
 	{ "adc122s021",	1},
+	{ "adc108s022", 1},
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, adc128_id);
Signature · 1 line
2.4.5

A message that is not in the archive (sent off-list or not yet received): 1437581064-9733-2-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org

#4 lore raw

Re: [PATCH 2/4] iio: adc: ti-adc128s052: Add adc108s022 ID

On Wed, Jul 22, 2015 at 06:04:22PM +0200, Denis Carikli wrote:

Where is the commit log?

https://www.kernel.org/doc/Documentation/SubmittingPatches

Quoted 52 lines
---
 drivers/iio/adc/Kconfig         | 6 +++---
 drivers/iio/adc/ti-adc128s052.c | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/iio/adc/Kconfig +3 -3
index 233d47b..ae92f23 100644
@@ -313,11 +313,11 @@ config TI_ADC081C
 	  called ti-adc081c.
 
 config TI_ADC128S052
-	tristate "Texas Instruments ADC128S052/ADC122S021"
+	tristate "Texas Instruments ADC128S052, ADC122S021 and ADC108S022"
 	depends on SPI
 	help
-	  If you say yes here you get support for Texas Instruments ADC128S052
-	  and ADC122S021 chips.
+	  If you say yes here you get support for Texas Instruments ADC128S052,
+	  ADC122S021 and ADC108S022 chips.
 
 	  This driver can also be built as a module. If so, the module will be
 	  called ti-adc128s052.
drivers/iio/adc/ti-adc128s052.c +2 -0
index 915be6b..8aca0ff 100644
@@ -5,6 +5,7 @@
  * Datasheets can be found here:
  * http://www.ti.com/lit/ds/symlink/adc128s052.pdf
  * http://www.ti.com/lit/ds/symlink/adc122s021.pdf
+ * http://www.ti.com/lit/ds/symlink/adc108s022.pdf
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -177,6 +178,7 @@ static int adc128_remove(struct spi_device *spi)
 static const struct spi_device_id adc128_id[] = {
 	{ "adc128s052", 0},	/* index into adc128_config */
 	{ "adc122s021",	1},
+	{ "adc108s022", 1},
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, adc128_id);
Signature · 6 lines
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

Re: [PATCH 2/4] iio: adc: ti-adc128s052: Add adc108s022 ID

In reply to a message not in the archive
Quoted 1 line · Denis Carikli

Given this is a 10 bit convertor and the one you are effectively claiming it is compatible with is a 12 bit convertor, you have more to do in the driver than this (slightly!).

The issue is in adc128_read_raw which is assuming 12 bits for IIO_CHAN_INFO_SCALE.

Quoted 45 lines
---
 drivers/iio/adc/Kconfig         | 6 +++---
 drivers/iio/adc/ti-adc128s052.c | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/iio/adc/Kconfig +3 -3
index 233d47b..ae92f23 100644
@@ -313,11 +313,11 @@ config TI_ADC081C
 	  called ti-adc081c.
 
 config TI_ADC128S052
-	tristate "Texas Instruments ADC128S052/ADC122S021"
+	tristate "Texas Instruments ADC128S052, ADC122S021 and ADC108S022"
 	depends on SPI
 	help
-	  If you say yes here you get support for Texas Instruments ADC128S052
-	  and ADC122S021 chips.
+	  If you say yes here you get support for Texas Instruments ADC128S052,
+	  ADC122S021 and ADC108S022 chips.
 
 	  This driver can also be built as a module. If so, the module will be
 	  called ti-adc128s052.
drivers/iio/adc/ti-adc128s052.c +2 -0
index 915be6b..8aca0ff 100644
@@ -5,6 +5,7 @@
  * Datasheets can be found here:
  * http://www.ti.com/lit/ds/symlink/adc128s052.pdf
  * http://www.ti.com/lit/ds/symlink/adc122s021.pdf
+ * http://www.ti.com/lit/ds/symlink/adc108s022.pdf
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -177,6 +178,7 @@ static int adc128_remove(struct spi_device *spi)
 static const struct spi_device_id adc128_id[] = {
 	{ "adc128s052", 0},	/* index into adc128_config */
 	{ "adc122s021",	1},
+	{ "adc108s022", 1},
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, adc128_id);
#6 lore raw

PATCH 3/4 iio: ti-adc128s052: Documentation: Add adc108s022 ID

In reply to a message not in the archive
---
 Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt +2 -2
index 15ca6b4..c8a958d 100644
@@ -1,7 +1,7 @@
-* Texas Instruments' ADC128S052 and ADC122S021 ADC chip
+* Texas Instruments' ADC128S052, ADC122S021 and ADC108S022 ADC chips
 
 Required properties:
- - compatible: Should be "ti,adc128s052" or "ti,adc122s021"
+ - compatible: Should be "ti,adc128s052", "ti,adc122s021" or "ti,adc108s022"
  - reg: spi chip select number for the device
  - vref-supply: The regulator supply for ADC reference voltage
 
Signature · 1 line
2.4.5

A message that is not in the archive (sent off-list or not yet received): 1437581064-9733-3-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org

#8 lore raw

Re: [PATCH 3/4] iio: ti-adc128s052: Documentation: Add adc108s022 ID

Quoted 1 line · Denis Carikli

Part of the same job as patch 2. Please roll them into a single patch.

Quoted 19 lines
---
 Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt +2 -2
index 15ca6b4..c8a958d 100644
@@ -1,7 +1,7 @@
-* Texas Instruments' ADC128S052 and ADC122S021 ADC chip
+* Texas Instruments' ADC128S052, ADC122S021 and ADC108S022 ADC chips
 
 Required properties:
- - compatible: Should be "ti,adc128s052" or "ti,adc122s021"
+ - compatible: Should be "ti,adc128s052", "ti,adc122s021" or "ti,adc108s022"
  - reg: spi chip select number for the device
  - vref-supply: The regulator supply for ADC reference voltage
 
#9 lore raw

PATCH 4/4 iio: adc: ti-adc128s052: Add devicetree support

In reply to a message not in the archive
---
 drivers/iio/adc/ti-adc128s052.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-adc128s052.c +13 -1
index 8aca0ff..2558508 100644
@@ -13,10 +13,11 @@
  */
 
 #include <linux/err.h>
-#include <linux/spi/spi.h>
 #include <linux/module.h>
 #include <linux/iio/iio.h>
+#include <linux/of.h>
 #include <linux/regulator/consumer.h>
+#include <linux/spi/spi.h>
 
 struct adc128_configuration {
 	const struct iio_chan_spec	*channels;
@@ -183,10 +184,21 @@ static const struct spi_device_id adc128_id[] = {
 };
 MODULE_DEVICE_TABLE(spi, adc128_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id adc128_of_match[] = {
+	{ .compatible = "ti,adc128s052" },
+	{ .compatible = "ti,adc122s021" },
+	{ .compatible = "ti,adc108s022" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, adc128_of_match);
+#endif
+
 static struct spi_driver adc128_driver = {
 	.driver = {
 		.name = "adc128s052",
 		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(adc128_of_match),
 	},
 	.probe = adc128_probe,
 	.remove = adc128_remove,
Signature · 1 line
2.4.5

A message that is not in the archive (sent off-list or not yet received): 1437581064-9733-4-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org

#11 lore raw

Re: [PATCH 4/4] iio: adc: ti-adc128s052: Add devicetree support

Quoted 10 lines · Denis Carikli
---
 drivers/iio/adc/ti-adc128s052.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/iio/adc/ti-adc128s052.c +0 -0
index 8aca0ff..2558508 100644

drivers/iio/adc/ti-adc128s052.c line 20

Quoted 9 lines
drivers/iio/adc/ti-adc128s052.c +2 -1
@@ -13,10 +13,11 @@
  */
 
 #include <linux/err.h>
-#include <linux/spi/spi.h>
 #include <linux/module.h>
 #include <linux/iio/iio.h>
+#include <linux/of.h>
 #include <linux/regulator/consumer.h>
+#include <linux/spi/spi.h>

Why the reorder?

Quoted 26 lines
drivers/iio/adc/ti-adc128s052.c +11 -0
 struct adc128_configuration {
 	const struct iio_chan_spec	*channels;
@@ -183,10 +184,21 @@ static const struct spi_device_id adc128_id[] = {
 };
 MODULE_DEVICE_TABLE(spi, adc128_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id adc128_of_match[] = {
+	{ .compatible = "ti,adc128s052" },
+	{ .compatible = "ti,adc122s021" },
+	{ .compatible = "ti,adc108s022" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, adc128_of_match);
+#endif
+
 static struct spi_driver adc128_driver = {
 	.driver = {
 		.name = "adc128s052",
 		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(adc128_of_match),
 	},
 	.probe = adc128_probe,
 	.remove = adc128_remove,
#12 lore raw
In reply to a message not in the archive
Quoted 12 lines · Denis Carikli

Without that fix, adc->chip_info is NULL in mcp320x_read_raw

---
 drivers/iio/adc/mcp320x.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/adc/mcp320x.c +0 -0
index 8d9c9b9..fccb2dc 100644

drivers/iio/adc/mcp320x.c static int mcp320x_probe(struct spi_device *spi) · line 305

Quoted 7 lines
drivers/iio/adc/mcp320x.c +1 -0
@@ -299,6 +299,7 @@ static int mcp320x_probe(struct spi_device *spi)
 	indio_dev->channels = chip_info->channels;
 	indio_dev->num_channels = chip_info->num_channels;
 
+	adc->chip_info = chip_info;
 	adc->transfer[0].tx_buf = &adc->tx_buf;
 	adc->transfer[0].len = sizeof(adc->tx_buf);
 	adc->transfer[1].rx_buf = adc->rx_buf;

This issue has already been dealt with.

http://www.gossamer-threads.com/lists/linux/kernel/2214469

Quoted 7 lines
Signature · 6 lines
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html