* [PATCH 1/5] iio: adc: cc10001: Fix the channel number mapping
2015-05-07 21:22 [PATCH 0/5] IIO: cc10001 assorted fixes Ezequiel Garcia
@ 2015-05-07 21:22 ` Ezequiel Garcia
2015-05-08 13:36 ` Jonathan Cameron
2015-05-07 21:22 ` [PATCH 2/5] iio: adc: cc10001: Fix incorrect use of power-up/power-down register Ezequiel Garcia
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Ezequiel Garcia @ 2015-05-07 21:22 UTC (permalink / raw)
To: linux-iio, Jonathan Cameron, Lars-Peter Clausen
Cc: Naidu Tellapati, James Hartley, phani.movva, Ezequiel Garcia
From: Naidu Tellapati <naidu.tellapati@imgtec.com>
When some of the ADC channels are reserved for remote CPUs,
the scan index and the corresponding channel number doesn't
match. This leads to convesion on the incorrect channel during
triggered capture.
Fix this by using a scan index to channel mapping encoded
in the iio_chan_spec for this purpose while starting conversion
on a particular ADC channel in trigger handler.
Also, the channel_map is not really used anywhere but in probe(), so
no need to keep track of it. Remove it from device structure.
While here, add 1 to number of channels to register timestamp channel
with the IIO core.
Fixes: 1664f6a5b0c8 ("iio: adc: Cosmic Circuits 10001 ADC driver")
Signed-off-by: Naidu Tellapati <naidu.tellapati@imgtec.com>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
---
drivers/iio/adc/cc10001_adc.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
index 51e2a83..357e6c2 100644
--- a/drivers/iio/adc/cc10001_adc.c
+++ b/drivers/iio/adc/cc10001_adc.c
@@ -62,7 +62,6 @@ struct cc10001_adc_device {
u16 *buf;
struct mutex lock;
- unsigned long channel_map;
unsigned int start_delay_ns;
unsigned int eoc_delay_ns;
};
@@ -129,6 +128,7 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
struct iio_dev *indio_dev;
unsigned int delay_ns;
unsigned int channel;
+ unsigned int scan_idx;
bool sample_invalid;
u16 *data;
int i;
@@ -150,9 +150,10 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
i = 0;
sample_invalid = false;
- for_each_set_bit(channel, indio_dev->active_scan_mask,
+ for_each_set_bit(scan_idx, indio_dev->active_scan_mask,
indio_dev->masklength) {
+ channel = indio_dev->channels[scan_idx].channel;
cc10001_adc_start(adc_dev, channel);
data[i] = cc10001_adc_poll_done(indio_dev, channel, delay_ns);
@@ -255,22 +256,22 @@ static const struct iio_info cc10001_adc_info = {
.update_scan_mode = &cc10001_update_scan_mode,
};
-static int cc10001_adc_channel_init(struct iio_dev *indio_dev)
+static int cc10001_adc_channel_init(struct iio_dev *indio_dev,
+ unsigned long channel_map)
{
- struct cc10001_adc_device *adc_dev = iio_priv(indio_dev);
struct iio_chan_spec *chan_array, *timestamp;
unsigned int bit, idx = 0;
- indio_dev->num_channels = bitmap_weight(&adc_dev->channel_map,
- CC10001_ADC_NUM_CHANNELS);
+ indio_dev->num_channels = bitmap_weight(&channel_map,
+ CC10001_ADC_NUM_CHANNELS) + 1;
- chan_array = devm_kcalloc(&indio_dev->dev, indio_dev->num_channels + 1,
+ chan_array = devm_kcalloc(&indio_dev->dev, indio_dev->num_channels,
sizeof(struct iio_chan_spec),
GFP_KERNEL);
if (!chan_array)
return -ENOMEM;
- for_each_set_bit(bit, &adc_dev->channel_map, CC10001_ADC_NUM_CHANNELS) {
+ for_each_set_bit(bit, &channel_map, CC10001_ADC_NUM_CHANNELS) {
struct iio_chan_spec *chan = &chan_array[idx];
chan->type = IIO_VOLTAGE;
@@ -305,6 +306,7 @@ static int cc10001_adc_probe(struct platform_device *pdev)
unsigned long adc_clk_rate;
struct resource *res;
struct iio_dev *indio_dev;
+ unsigned long channel_map;
int ret;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev));
@@ -313,9 +315,9 @@ static int cc10001_adc_probe(struct platform_device *pdev)
adc_dev = iio_priv(indio_dev);
- adc_dev->channel_map = GENMASK(CC10001_ADC_NUM_CHANNELS - 1, 0);
+ channel_map = GENMASK(CC10001_ADC_NUM_CHANNELS - 1, 0);
if (!of_property_read_u32(node, "adc-reserved-channels", &ret))
- adc_dev->channel_map &= ~ret;
+ channel_map &= ~ret;
adc_dev->reg = devm_regulator_get(&pdev->dev, "vref");
if (IS_ERR(adc_dev->reg))
@@ -361,7 +363,7 @@ static int cc10001_adc_probe(struct platform_device *pdev)
adc_dev->start_delay_ns = adc_dev->eoc_delay_ns * CC10001_WAIT_CYCLES;
/* Setup the ADC channels available on the device */
- ret = cc10001_adc_channel_init(indio_dev);
+ ret = cc10001_adc_channel_init(indio_dev, channel_map);
if (ret < 0)
goto err_disable_clk;
--
2.3.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 1/5] iio: adc: cc10001: Fix the channel number mapping
2015-05-07 21:22 ` [PATCH 1/5] iio: adc: cc10001: Fix the channel number mapping Ezequiel Garcia
@ 2015-05-08 13:36 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2015-05-08 13:36 UTC (permalink / raw)
To: Ezequiel Garcia, linux-iio, Lars-Peter Clausen
Cc: Naidu Tellapati, James Hartley, phani.movva
On 07/05/15 17:22, Ezequiel Garcia wrote:
> From: Naidu Tellapati <naidu.tellapati@imgtec.com>
>
> When some of the ADC channels are reserved for remote CPUs,
> the scan index and the corresponding channel number doesn't
> match. This leads to convesion on the incorrect channel during
> triggered capture.
>
> Fix this by using a scan index to channel mapping encoded
> in the iio_chan_spec for this purpose while starting conversion
> on a particular ADC channel in trigger handler.
>
> Also, the channel_map is not really used anywhere but in probe(), so
> no need to keep track of it. Remove it from device structure.
>
> While here, add 1 to number of channels to register timestamp channel
> with the IIO core.
>
> Fixes: 1664f6a5b0c8 ("iio: adc: Cosmic Circuits 10001 ADC driver")
> Signed-off-by: Naidu Tellapati <naidu.tellapati@imgtec.com>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
Applied to the fixes-togreg branch. Will probably send onwards sometime
this weekend.
Jonathan
> ---
> drivers/iio/adc/cc10001_adc.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
> index 51e2a83..357e6c2 100644
> --- a/drivers/iio/adc/cc10001_adc.c
> +++ b/drivers/iio/adc/cc10001_adc.c
> @@ -62,7 +62,6 @@ struct cc10001_adc_device {
> u16 *buf;
>
> struct mutex lock;
> - unsigned long channel_map;
> unsigned int start_delay_ns;
> unsigned int eoc_delay_ns;
> };
> @@ -129,6 +128,7 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
> struct iio_dev *indio_dev;
> unsigned int delay_ns;
> unsigned int channel;
> + unsigned int scan_idx;
> bool sample_invalid;
> u16 *data;
> int i;
> @@ -150,9 +150,10 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
>
> i = 0;
> sample_invalid = false;
> - for_each_set_bit(channel, indio_dev->active_scan_mask,
> + for_each_set_bit(scan_idx, indio_dev->active_scan_mask,
> indio_dev->masklength) {
>
> + channel = indio_dev->channels[scan_idx].channel;
> cc10001_adc_start(adc_dev, channel);
>
> data[i] = cc10001_adc_poll_done(indio_dev, channel, delay_ns);
> @@ -255,22 +256,22 @@ static const struct iio_info cc10001_adc_info = {
> .update_scan_mode = &cc10001_update_scan_mode,
> };
>
> -static int cc10001_adc_channel_init(struct iio_dev *indio_dev)
> +static int cc10001_adc_channel_init(struct iio_dev *indio_dev,
> + unsigned long channel_map)
> {
> - struct cc10001_adc_device *adc_dev = iio_priv(indio_dev);
> struct iio_chan_spec *chan_array, *timestamp;
> unsigned int bit, idx = 0;
>
> - indio_dev->num_channels = bitmap_weight(&adc_dev->channel_map,
> - CC10001_ADC_NUM_CHANNELS);
> + indio_dev->num_channels = bitmap_weight(&channel_map,
> + CC10001_ADC_NUM_CHANNELS) + 1;
>
> - chan_array = devm_kcalloc(&indio_dev->dev, indio_dev->num_channels + 1,
> + chan_array = devm_kcalloc(&indio_dev->dev, indio_dev->num_channels,
> sizeof(struct iio_chan_spec),
> GFP_KERNEL);
> if (!chan_array)
> return -ENOMEM;
>
> - for_each_set_bit(bit, &adc_dev->channel_map, CC10001_ADC_NUM_CHANNELS) {
> + for_each_set_bit(bit, &channel_map, CC10001_ADC_NUM_CHANNELS) {
> struct iio_chan_spec *chan = &chan_array[idx];
>
> chan->type = IIO_VOLTAGE;
> @@ -305,6 +306,7 @@ static int cc10001_adc_probe(struct platform_device *pdev)
> unsigned long adc_clk_rate;
> struct resource *res;
> struct iio_dev *indio_dev;
> + unsigned long channel_map;
> int ret;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev));
> @@ -313,9 +315,9 @@ static int cc10001_adc_probe(struct platform_device *pdev)
>
> adc_dev = iio_priv(indio_dev);
>
> - adc_dev->channel_map = GENMASK(CC10001_ADC_NUM_CHANNELS - 1, 0);
> + channel_map = GENMASK(CC10001_ADC_NUM_CHANNELS - 1, 0);
> if (!of_property_read_u32(node, "adc-reserved-channels", &ret))
> - adc_dev->channel_map &= ~ret;
> + channel_map &= ~ret;
>
> adc_dev->reg = devm_regulator_get(&pdev->dev, "vref");
> if (IS_ERR(adc_dev->reg))
> @@ -361,7 +363,7 @@ static int cc10001_adc_probe(struct platform_device *pdev)
> adc_dev->start_delay_ns = adc_dev->eoc_delay_ns * CC10001_WAIT_CYCLES;
>
> /* Setup the ADC channels available on the device */
> - ret = cc10001_adc_channel_init(indio_dev);
> + ret = cc10001_adc_channel_init(indio_dev, channel_map);
> if (ret < 0)
> goto err_disable_clk;
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/5] iio: adc: cc10001: Fix incorrect use of power-up/power-down register
2015-05-07 21:22 [PATCH 0/5] IIO: cc10001 assorted fixes Ezequiel Garcia
2015-05-07 21:22 ` [PATCH 1/5] iio: adc: cc10001: Fix the channel number mapping Ezequiel Garcia
@ 2015-05-07 21:22 ` Ezequiel Garcia
2015-05-08 13:36 ` Jonathan Cameron
2015-05-07 21:22 ` [PATCH 3/5] iio: adc: cc10001: Fix regulator_get_voltage() return value check Ezequiel Garcia
2015-05-07 21:22 ` [PATCH 4/5] iio: adc: cc10001: Add delay before setting START bit Ezequiel Garcia
3 siblings, 1 reply; 8+ messages in thread
From: Ezequiel Garcia @ 2015-05-07 21:22 UTC (permalink / raw)
To: linux-iio, Jonathan Cameron, Lars-Peter Clausen
Cc: Naidu Tellapati, James Hartley, phani.movva, Ezequiel Garcia
From: Naidu Tellapati <naidu.tellapati@imgtec.com>
At present we are incorrectly setting the register to 0x1 to power up
the ADC. Since it is an active high power down register, we need to set
the register to 0x0 to actually power up. Conversely, writing 0x1 to the
register powers it down.
This commit adds a couple of helpers to make the code clearer and then
use them to do the power-up/power-down properly.
Fixes: 1664f6a5b0c8 ("iio: adc: Cosmic Circuits 10001 ADC driver")
Signed-off-by: Naidu Tellapati <naidu.tellapati@imgtec.com>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
---
drivers/iio/adc/cc10001_adc.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
index 357e6c2..cf6c6fb 100644
--- a/drivers/iio/adc/cc10001_adc.c
+++ b/drivers/iio/adc/cc10001_adc.c
@@ -35,8 +35,9 @@
#define CC10001_ADC_EOC_SET BIT(0)
#define CC10001_ADC_CHSEL_SAMPLED 0x0c
-#define CC10001_ADC_POWER_UP 0x10
-#define CC10001_ADC_POWER_UP_SET BIT(0)
+#define CC10001_ADC_POWER_DOWN 0x10
+#define CC10001_ADC_POWER_DOWN_SET BIT(0)
+
#define CC10001_ADC_DEBUG 0x14
#define CC10001_ADC_DATA_COUNT 0x20
@@ -78,6 +79,20 @@ static inline u32 cc10001_adc_read_reg(struct cc10001_adc_device *adc_dev,
return readl(adc_dev->reg_base + reg);
}
+static void cc10001_adc_power_up(struct cc10001_adc_device *adc_dev)
+{
+ cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_DOWN,
+ ~CC10001_ADC_POWER_DOWN_SET);
+
+ ndelay(adc_dev->start_delay_ns);
+}
+
+static void cc10001_adc_power_down(struct cc10001_adc_device *adc_dev)
+{
+ cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_DOWN,
+ CC10001_ADC_POWER_DOWN_SET);
+}
+
static void cc10001_adc_start(struct cc10001_adc_device *adc_dev,
unsigned int channel)
{
@@ -139,11 +154,7 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
mutex_lock(&adc_dev->lock);
- cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP,
- CC10001_ADC_POWER_UP_SET);
-
- /* Wait for 8 (6+2) clock cycles before activating START */
- ndelay(adc_dev->start_delay_ns);
+ cc10001_adc_power_up(adc_dev);
/* Calculate delay step for eoc and sampled data */
delay_ns = adc_dev->eoc_delay_ns / CC10001_MAX_POLL_COUNT;
@@ -167,7 +178,7 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
}
done:
- cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP, 0);
+ cc10001_adc_power_down(adc_dev);
mutex_unlock(&adc_dev->lock);
@@ -186,11 +197,7 @@ static u16 cc10001_adc_read_raw_voltage(struct iio_dev *indio_dev,
unsigned int delay_ns;
u16 val;
- cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP,
- CC10001_ADC_POWER_UP_SET);
-
- /* Wait for 8 (6+2) clock cycles before activating START */
- ndelay(adc_dev->start_delay_ns);
+ cc10001_adc_power_up(adc_dev);
/* Calculate delay step for eoc and sampled data */
delay_ns = adc_dev->eoc_delay_ns / CC10001_MAX_POLL_COUNT;
@@ -199,7 +206,7 @@ static u16 cc10001_adc_read_raw_voltage(struct iio_dev *indio_dev,
val = cc10001_adc_poll_done(indio_dev, chan->channel, delay_ns);
- cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP, 0);
+ cc10001_adc_power_down(adc_dev);
return val;
}
--
2.3.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 2/5] iio: adc: cc10001: Fix incorrect use of power-up/power-down register
2015-05-07 21:22 ` [PATCH 2/5] iio: adc: cc10001: Fix incorrect use of power-up/power-down register Ezequiel Garcia
@ 2015-05-08 13:36 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2015-05-08 13:36 UTC (permalink / raw)
To: Ezequiel Garcia, linux-iio, Lars-Peter Clausen
Cc: Naidu Tellapati, James Hartley, phani.movva
On 07/05/15 17:22, Ezequiel Garcia wrote:
> From: Naidu Tellapati <naidu.tellapati@imgtec.com>
>
> At present we are incorrectly setting the register to 0x1 to power up
> the ADC. Since it is an active high power down register, we need to set
> the register to 0x0 to actually power up. Conversely, writing 0x1 to the
> register powers it down.
>
> This commit adds a couple of helpers to make the code clearer and then
> use them to do the power-up/power-down properly.
>
> Fixes: 1664f6a5b0c8 ("iio: adc: Cosmic Circuits 10001 ADC driver")
> Signed-off-by: Naidu Tellapati <naidu.tellapati@imgtec.com>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
Applied to the fixes-togreg branch of iio.git.
Thanks,
Jonathan
> ---
> drivers/iio/adc/cc10001_adc.c | 35 +++++++++++++++++++++--------------
> 1 file changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
> index 357e6c2..cf6c6fb 100644
> --- a/drivers/iio/adc/cc10001_adc.c
> +++ b/drivers/iio/adc/cc10001_adc.c
> @@ -35,8 +35,9 @@
> #define CC10001_ADC_EOC_SET BIT(0)
>
> #define CC10001_ADC_CHSEL_SAMPLED 0x0c
> -#define CC10001_ADC_POWER_UP 0x10
> -#define CC10001_ADC_POWER_UP_SET BIT(0)
> +#define CC10001_ADC_POWER_DOWN 0x10
> +#define CC10001_ADC_POWER_DOWN_SET BIT(0)
> +
> #define CC10001_ADC_DEBUG 0x14
> #define CC10001_ADC_DATA_COUNT 0x20
>
> @@ -78,6 +79,20 @@ static inline u32 cc10001_adc_read_reg(struct cc10001_adc_device *adc_dev,
> return readl(adc_dev->reg_base + reg);
> }
>
> +static void cc10001_adc_power_up(struct cc10001_adc_device *adc_dev)
> +{
> + cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_DOWN,
> + ~CC10001_ADC_POWER_DOWN_SET);
> +
> + ndelay(adc_dev->start_delay_ns);
> +}
> +
> +static void cc10001_adc_power_down(struct cc10001_adc_device *adc_dev)
> +{
> + cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_DOWN,
> + CC10001_ADC_POWER_DOWN_SET);
> +}
> +
> static void cc10001_adc_start(struct cc10001_adc_device *adc_dev,
> unsigned int channel)
> {
> @@ -139,11 +154,7 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
>
> mutex_lock(&adc_dev->lock);
>
> - cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP,
> - CC10001_ADC_POWER_UP_SET);
> -
> - /* Wait for 8 (6+2) clock cycles before activating START */
> - ndelay(adc_dev->start_delay_ns);
> + cc10001_adc_power_up(adc_dev);
>
> /* Calculate delay step for eoc and sampled data */
> delay_ns = adc_dev->eoc_delay_ns / CC10001_MAX_POLL_COUNT;
> @@ -167,7 +178,7 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p)
> }
>
> done:
> - cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP, 0);
> + cc10001_adc_power_down(adc_dev);
>
> mutex_unlock(&adc_dev->lock);
>
> @@ -186,11 +197,7 @@ static u16 cc10001_adc_read_raw_voltage(struct iio_dev *indio_dev,
> unsigned int delay_ns;
> u16 val;
>
> - cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP,
> - CC10001_ADC_POWER_UP_SET);
> -
> - /* Wait for 8 (6+2) clock cycles before activating START */
> - ndelay(adc_dev->start_delay_ns);
> + cc10001_adc_power_up(adc_dev);
>
> /* Calculate delay step for eoc and sampled data */
> delay_ns = adc_dev->eoc_delay_ns / CC10001_MAX_POLL_COUNT;
> @@ -199,7 +206,7 @@ static u16 cc10001_adc_read_raw_voltage(struct iio_dev *indio_dev,
>
> val = cc10001_adc_poll_done(indio_dev, chan->channel, delay_ns);
>
> - cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP, 0);
> + cc10001_adc_power_down(adc_dev);
>
> return val;
> }
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/5] iio: adc: cc10001: Fix regulator_get_voltage() return value check
2015-05-07 21:22 [PATCH 0/5] IIO: cc10001 assorted fixes Ezequiel Garcia
2015-05-07 21:22 ` [PATCH 1/5] iio: adc: cc10001: Fix the channel number mapping Ezequiel Garcia
2015-05-07 21:22 ` [PATCH 2/5] iio: adc: cc10001: Fix incorrect use of power-up/power-down register Ezequiel Garcia
@ 2015-05-07 21:22 ` Ezequiel Garcia
2015-05-08 13:37 ` Jonathan Cameron
2015-05-07 21:22 ` [PATCH 4/5] iio: adc: cc10001: Add delay before setting START bit Ezequiel Garcia
3 siblings, 1 reply; 8+ messages in thread
From: Ezequiel Garcia @ 2015-05-07 21:22 UTC (permalink / raw)
To: linux-iio, Jonathan Cameron, Lars-Peter Clausen
Cc: Naidu Tellapati, James Hartley, phani.movva, Ezequiel Garcia
From: Naidu Tellapati <naidu.tellapati@imgtec.com>
regulator_get_voltage() returns a non-negative value in case of success,
and a negative error in case of error. Let's fix this.
Fixes: 1664f6a5b0c8 ("iio: adc: Cosmic Circuits 10001 ADC driver")
Signed-off-by: Naidu Tellapati <naidu.tellapati@imgtec.com>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
---
drivers/iio/adc/cc10001_adc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
index cf6c6fb..5302bbb 100644
--- a/drivers/iio/adc/cc10001_adc.c
+++ b/drivers/iio/adc/cc10001_adc.c
@@ -232,7 +232,7 @@ static int cc10001_adc_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
ret = regulator_get_voltage(adc_dev->reg);
- if (ret)
+ if (ret < 0)
return ret;
*val = ret / 1000;
--
2.3.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 3/5] iio: adc: cc10001: Fix regulator_get_voltage() return value check
2015-05-07 21:22 ` [PATCH 3/5] iio: adc: cc10001: Fix regulator_get_voltage() return value check Ezequiel Garcia
@ 2015-05-08 13:37 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2015-05-08 13:37 UTC (permalink / raw)
To: Ezequiel Garcia, linux-iio, Lars-Peter Clausen
Cc: Naidu Tellapati, James Hartley, phani.movva
On 07/05/15 17:22, Ezequiel Garcia wrote:
> From: Naidu Tellapati <naidu.tellapati@imgtec.com>
>
> regulator_get_voltage() returns a non-negative value in case of success,
> and a negative error in case of error. Let's fix this.
>
> Fixes: 1664f6a5b0c8 ("iio: adc: Cosmic Circuits 10001 ADC driver")
> Signed-off-by: Naidu Tellapati <naidu.tellapati@imgtec.com>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
Applied to the fixes-togreg branch of iio.git also marked for
stable (as are the previous 2).
> ---
> drivers/iio/adc/cc10001_adc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
> index cf6c6fb..5302bbb 100644
> --- a/drivers/iio/adc/cc10001_adc.c
> +++ b/drivers/iio/adc/cc10001_adc.c
> @@ -232,7 +232,7 @@ static int cc10001_adc_read_raw(struct iio_dev *indio_dev,
>
> case IIO_CHAN_INFO_SCALE:
> ret = regulator_get_voltage(adc_dev->reg);
> - if (ret)
> + if (ret < 0)
> return ret;
>
> *val = ret / 1000;
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/5] iio: adc: cc10001: Add delay before setting START bit
2015-05-07 21:22 [PATCH 0/5] IIO: cc10001 assorted fixes Ezequiel Garcia
` (2 preceding siblings ...)
2015-05-07 21:22 ` [PATCH 3/5] iio: adc: cc10001: Fix regulator_get_voltage() return value check Ezequiel Garcia
@ 2015-05-07 21:22 ` Ezequiel Garcia
3 siblings, 0 replies; 8+ messages in thread
From: Ezequiel Garcia @ 2015-05-07 21:22 UTC (permalink / raw)
To: linux-iio, Jonathan Cameron, Lars-Peter Clausen
Cc: Naidu Tellapati, James Hartley, phani.movva, Ezequiel Garcia
From: Naidu Tellapati <naidu.tellapati@imgtec.com>
According to hardware team there should be some delay after
setting channel number, start mode and before setting START.
Add a one microsecond delay for this purpose.
Fixes: 1664f6a5b0c8 ("iio: adc: Cosmic Circuits 10001 ADC driver")
Signed-off-by: Naidu Tellapati <naidu.tellapati@imgtec.com>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
---
drivers/iio/adc/cc10001_adc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
index 5302bbb..10c734d 100644
--- a/drivers/iio/adc/cc10001_adc.c
+++ b/drivers/iio/adc/cc10001_adc.c
@@ -102,6 +102,7 @@ static void cc10001_adc_start(struct cc10001_adc_device *adc_dev,
val = (channel & CC10001_ADC_CH_MASK) | CC10001_ADC_MODE_SINGLE_CONV;
cc10001_adc_write_reg(adc_dev, CC10001_ADC_CONFIG, val);
+ udelay(1);
val = cc10001_adc_read_reg(adc_dev, CC10001_ADC_CONFIG);
val = val | CC10001_ADC_START_CONV;
cc10001_adc_write_reg(adc_dev, CC10001_ADC_CONFIG, val);
--
2.3.3
^ permalink raw reply related [flat|nested] 8+ messages in thread