Skip to content

Commit e7215fe

Browse files
hofratjic23
authored andcommitted
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 03b262f ("iio:pressure: initial zpa2326 barometer support") Signed-off-by: Nicholas Mc Guire <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 6fb3481 commit e7215fe

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

drivers/iio/pressure/zpa2326.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -867,12 +867,13 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev,
867867
{
868868
int ret;
869869
unsigned int val;
870+
long timeout;
870871

871872
zpa2326_dbg(indio_dev, "waiting for one shot completion interrupt");
872873

873-
ret = wait_for_completion_interruptible_timeout(
874+
timeout = wait_for_completion_interruptible_timeout(
874875
&private->data_ready, ZPA2326_CONVERSION_JIFFIES);
875-
if (ret > 0)
876+
if (timeout > 0)
876877
/*
877878
* Interrupt handler completed before timeout: return operation
878879
* status.
@@ -882,13 +883,16 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev,
882883
/* Clear all interrupts just to be sure. */
883884
regmap_read(private->regmap, ZPA2326_INT_SOURCE_REG, &val);
884885

885-
if (!ret)
886+
if (!timeout) {
886887
/* Timed out. */
888+
zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
889+
timeout);
887890
ret = -ETIME;
888-
889-
if (ret != -ERESTARTSYS)
890-
zpa2326_warn(indio_dev, "no one shot interrupt occurred (%d)",
891-
ret);
891+
} else if (timeout < 0) {
892+
zpa2326_warn(indio_dev,
893+
"wait for one shot interrupt cancelled");
894+
ret = -ERESTARTSYS;
895+
}
892896

893897
return ret;
894898
}

0 commit comments

Comments
 (0)