Commit 10bef289 authored by Srinivas Pandruvada's avatar Srinivas Pandruvada Committed by Jonathan Cameron

iio: gyro: bmg160: Error handling when mode set fails

When mode set fails due to some transient failures, it will atleast
reset the state of runtime usage count and also let the runtime
suspend retry from the driver framework.
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent fbbba1f8
...@@ -250,6 +250,9 @@ static int bmg160_set_power_state(struct bmg160_data *data, bool on) ...@@ -250,6 +250,9 @@ static int bmg160_set_power_state(struct bmg160_data *data, bool on)
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, dev_err(&data->client->dev,
"Failed: bmg160_set_power_state for %d\n", on); "Failed: bmg160_set_power_state for %d\n", on);
if (on)
pm_runtime_put_noidle(&data->client->dev);
return ret; return ret;
} }
#endif #endif
...@@ -705,6 +708,7 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev, ...@@ -705,6 +708,7 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev,
ret = bmg160_setup_any_motion_interrupt(data, state); ret = bmg160_setup_any_motion_interrupt(data, state);
if (ret < 0) { if (ret < 0) {
bmg160_set_power_state(data, false);
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
return ret; return ret;
} }
...@@ -871,6 +875,7 @@ static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig, ...@@ -871,6 +875,7 @@ static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig,
else else
ret = bmg160_setup_new_data_interrupt(data, state); ret = bmg160_setup_new_data_interrupt(data, state);
if (ret < 0) { if (ret < 0) {
bmg160_set_power_state(data, false);
mutex_unlock(&data->mutex); mutex_unlock(&data->mutex);
return ret; return ret;
} }
...@@ -1169,8 +1174,15 @@ static int bmg160_runtime_suspend(struct device *dev) ...@@ -1169,8 +1174,15 @@ static int bmg160_runtime_suspend(struct device *dev)
{ {
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct bmg160_data *data = iio_priv(indio_dev); struct bmg160_data *data = iio_priv(indio_dev);
int ret;
return bmg160_set_mode(data, BMG160_MODE_SUSPEND); ret = bmg160_set_mode(data, BMG160_MODE_SUSPEND);
if (ret < 0) {
dev_err(&data->client->dev, "set mode failed\n");
return -EAGAIN;
}
return 0;
} }
static int bmg160_runtime_resume(struct device *dev) static int bmg160_runtime_resume(struct device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment