Skip to content

Commit

Permalink
iio: pressure: zpa2326: report interrupted case as failure
Browse files Browse the repository at this point in the history
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 03b262f ("iio:pressure: initial zpa2326 barometer support")
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Nicholas Mc Guire authored and Jonathan Cameron committed May 14, 2017
1 parent 6fb3481 commit e7215fe
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions drivers/iio/pressure/zpa2326.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
Expand Down

0 comments on commit e7215fe

Please sign in to comment.