summaryrefslogtreecommitdiff
path: root/drivers/iio/proximity
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-05-30 14:52:04 (GMT)
committerJonathan Cameron <jic23@kernel.org>2016-06-27 19:59:10 (GMT)
commit22ed1a1c1cceebff380b3f6f84d520a0b398509a (patch)
tree88ed54fdd9333135d44cf5dc0ebce6e3fa7cf512 /drivers/iio/proximity
parentaea7b1dc2bb7405f2d7827b202788fbee3912c1a (diff)
downloadlinux-22ed1a1c1cceebff380b3f6f84d520a0b398509a.tar.xz
iio: as3935: improve error reporting in as3935_event_work
gcc warns about a potentially uninitialized variable use in as3935_event_work: drivers/iio/proximity/as3935.c: In function ‘as3935_event_work’: drivers/iio/proximity/as3935.c:231:6: error: ‘val’ may be used uninitialized in this function [-Werror=maybe-uninitialized] This case specifically happens when spi_w8r8() fails with a negative return code. We check all other users of this function except this one. As the error is rather unlikely to happen after the device has already been initialized, this just adds a dev_warn(). Another warning already exists in the same function, but is missing a trailing '\n' character, so I'm fixing that too. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Matt Ranostay <mranostay@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/proximity')
-rw-r--r--drivers/iio/proximity/as3935.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index c12fde2..a9d5847 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -224,10 +224,16 @@ static void as3935_event_work(struct work_struct *work)
{
struct as3935_state *st;
int val;
+ int ret;
st = container_of(work, struct as3935_state, work.work);
- as3935_read(st, AS3935_INT, &val);
+ ret = as3935_read(st, AS3935_INT, &val);
+ if (ret) {
+ dev_warn(&st->spi->dev, "read error\n");
+ return;
+ }
+
val &= AS3935_INT_MASK;
switch (val) {
@@ -235,7 +241,7 @@ static void as3935_event_work(struct work_struct *work)
iio_trigger_poll(st->trig);
break;
case AS3935_NOISE_INT:
- dev_warn(&st->spi->dev, "noise level is too high");
+ dev_warn(&st->spi->dev, "noise level is too high\n");
break;
}
}