From: Hartmut Knaack Date: Mon, 27 Jul 2015 22:49:22 +0000 (+0200) Subject: iio:accel:stk8312: check for invalid value X-Git-Tag: v4.9.8~3706^2~139^2~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b41e63cf83affa50a6141eba52be1fbd05f29b21;p=platform%2Fkernel%2Flinux-rpi3.git iio:accel:stk8312: check for invalid value 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 Reviewed-by: Tiberiu Breana Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c index a553736..8280a37 100644 --- a/drivers/iio/accel/stk8312.c +++ b/drivers/iio/accel/stk8312.c @@ -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;