driver: kionix: Add checking whoami value at initialization.

spi_transaction() always returns success even without the sensor.
Check whoami value to make sure that the sensor is existed.

BUG=none
BRANCH=none
TEST=remove LID accel sensor from elm and see init failed log.
[1.258973 Lid Accel: 1: init failed: 4]

Change-Id: I55aa35bc9790e5dec61e22aa2f51243e29368a86
Signed-off-by: Yidi Lin <yidi.lin@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/453579
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
This commit is contained in:
Yidi Lin
2017-03-13 14:11:13 +08:00
committed by chrome-bot
parent cdfce3bc83
commit 1d8fcd4fab

View File

@@ -458,7 +458,7 @@ static int init(const struct motion_sensor_t *s)
msleep(1);
/* Read WHO_AM_I to be sure the device has booted */
ret = raw_read8(s->port, s->addr, reg, &val);
if (ret == EC_SUCCESS)
if (ret == EC_SUCCESS && val == KIONIX_WHO_AM_I_VAL(V(s)))
break;
/* Check for timeout. */