diff options
author | Nicholas Mc Guire <der.herr@hofr.at> | 2017-05-14 10:43:55 +0200 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2017-05-14 15:28:14 +0100 |
commit | e7215fe4d51e69c9d2608ad0c409d48e844d0adc (patch) | |
tree | 5013b8be1511f4b551882f62b86617907b1fbb7b | |
parent | 6fb34812c2a2a4cdcdad4452b9634892812fa97b (diff) | |
download | linux-e7215fe4d51e69c9d2608ad0c409d48e844d0adc.tar.gz linux-e7215fe4d51e69c9d2608ad0c409d48e844d0adc.tar.bz2 linux-e7215fe4d51e69c9d2608ad0c409d48e844d0adc.zip |
iio: pressure: zpa2326: report interrupted case as failure
If the timeout-case prints a warning message then probably the interrupted
case should also. Further, wait_for_completion_interruptible_timeout()
returns long not int.
Fixes: commit 03b262f2bbf4 ("iio:pressure: initial zpa2326 barometer support")
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/iio/pressure/zpa2326.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c index e58a0ad07477..c92a95f9f52c 100644 --- a/drivers/iio/pressure/zpa2326.c +++ b/drivers/iio/pressure/zpa2326.c @@ -867,12 +867,13 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev, { int ret; unsigned int val; + long timeout; zpa2326_dbg(indio_dev, "waiting for one shot completion interrupt"); - ret = wait_for_completion_interruptible_timeout( + timeout = wait_for_completion_interruptible_timeout( &private->data_ready, ZPA2326_CONVERSION_JIFFIES); - if (ret > 0) + if (timeout > 0) /* * Interrupt handler completed before timeout: return operation * status. @@ -882,13 +883,16 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev, /* Clear all interrupts just to be sure. */ regmap_read(private->regmap, ZPA2326_INT_SOURCE_REG, &val); - if (!ret) + if (!timeout) { /* Timed out. */ + zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)", + timeout); ret = -ETIME; - - if (ret != -ERESTARTSYS) - zpa2326_warn(indio_dev, "no one shot interrupt occurred (%d)", - ret); + } else if (timeout < 0) { + zpa2326_warn(indio_dev, + "wait for one shot interrupt cancelled"); + ret = -ERESTARTSYS; + } return ret; } |