aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-05-29 18:49:55 +0200
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-06-12 18:50:23 +0200
commit1460c152c53335b5403045d056502eda1204c33a (patch)
treebb16df188c7950042192f4829f0400ed4d95f94b /drivers/iio
parentiio: ti_am335x_adc: Allow to specify input line (diff)
downloadlinux-dev-1460c152c53335b5403045d056502eda1204c33a.tar.xz
linux-dev-1460c152c53335b5403045d056502eda1204c33a.zip
iio: ti_am335x_adc: check if we found the value
Usually we get all the values we wanted but it is possible, that te ADC unit is busy performing the conversation for the HW events. In that case -EBUSY is returned and the user may re-call the function. Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 8ffe52d58829..4427e8e46a7f 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -145,6 +145,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
int i;
unsigned int fifo1count, read;
u32 step = UINT_MAX;
+ bool found = false;
/*
* When the sub-system is first enabled,
@@ -169,11 +170,14 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
for (i = 0; i < fifo1count; i++) {
read = tiadc_readl(adc_dev, REG_FIFO1);
- if (read >> 16 == step)
+ if (read >> 16 == step) {
*val = read & 0xfff;
+ found = true;
+ }
}
am335x_tsc_se_update(adc_dev->mfd_tscadc);
-
+ if (found == false)
+ return -EBUSY;
return IIO_VAL_INT;
}