iio: light: apds9960: silence uninitialized variable warning
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 22 Apr 2016 10:04:14 +0000 (13:04 +0300)
committerJonathan Cameron <jic23@kernel.org>
Sat, 23 Apr 2016 21:18:09 +0000 (22:18 +0100)
It causes a static checker warning if we use "buf" on the failure path
so move that inside the if statement.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/light/apds9960.c

index 47fcd5ad4ff28ad5eb503e7c6c98da45a844d286..35928fb1b66a5d83eacc578125fd4a0743696f2e 100644 (file)
@@ -495,9 +495,10 @@ static int apds9960_read_raw(struct iio_dev *indio_dev,
                case IIO_INTENSITY:
                        ret = regmap_bulk_read(data->regmap, chan->address,
                                               &buf, 2);
-                       if (!ret)
+                       if (!ret) {
                                ret = IIO_VAL_INT;
-                       *val = le16_to_cpu(buf);
+                               *val = le16_to_cpu(buf);
+                       }
                        break;
                default:
                        ret = -EINVAL;