iio: accel: mma9553: check for error in reading initial activity and stepcnt

When configuring gpio, we need to read initial values for activity and
step count. This function may fail due to i2c read errors.

Check the error code returned by mma9553_read_activity_stepcnt
and return the appropriate error in gpio config function.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Reported-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
Irina Tirdea 2015-04-13 18:40:54 +03:00 committed by Jonathan Cameron
parent 476c41a73e
commit 1d052931c6
1 changed files with 6 additions and 3 deletions

View File

@ -365,9 +365,12 @@ static int mma9553_conf_gpio(struct mma9553_data *data)
return 0;
/* Save initial values for activity and stepcnt */
if (activity_enabled || ev_step_detect->enabled)
mma9553_read_activity_stepcnt(data, &data->activity,
&data->stepcnt);
if (activity_enabled || ev_step_detect->enabled) {
ret = mma9553_read_activity_stepcnt(data, &data->activity,
&data->stepcnt);
if (ret < 0)
return ret;
}
ret = mma9551_gpio_config(data->client,
MMA9553_DEFAULT_GPIO_PIN,