iio:accel:stk8312: check for invalid value
authorHartmut Knaack <knaack.h@gmx.de>
Mon, 27 Jul 2015 22:49:22 +0000 (00:49 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sun, 2 Aug 2015 18:13:49 +0000 (19:13 +0100)
Revision 1.2 of the datasheet recommends on page 22 to only write non-zero
values read from OTP register 0x70 into AFECTRL register.

Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Reviewed-by: Tiberiu Breana <tiberiu.a.breana@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/accel/stk8312.c

index a553736b6e5107f30f78ad499a3503ebe5f85c8f..8280a37e0068acd1cacd6c6a489d91b89a0cea89 100644 (file)
@@ -150,6 +150,8 @@ static int stk8312_otp_init(struct stk8312_data *data)
                goto exit_err;
 
        ret = i2c_smbus_read_byte_data(client, STK8312_REG_OTPDATA);
+       if (ret == 0)
+               ret = -EINVAL;
        if (ret < 0)
                goto exit_err;