aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2014-10-10 23:35:31 -0400
committerJonathan Cameron <jic23@kernel.org>2014-11-16 15:22:34 -0500
commitaaeecd80440bc5e06de7d2b741cd403325d8ca7a (patch)
tree174f39c8178256d4b51c21def116ca802a2cfed7 /drivers/iio
parent6896ab3a8cfe383cc0c98790b62245a84c6335f7 (diff)
iio: accel: bmc150: 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: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/accel/bmc150-accel.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index 22c096ce39ad..fdb101c48599 100644
--- a/drivers/iio/accel/bmc150-accel.c
+++ b/drivers/iio/accel/bmc150-accel.c
@@ -536,6 +536,9 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on)
536 if (ret < 0) { 536 if (ret < 0) {
537 dev_err(&data->client->dev, 537 dev_err(&data->client->dev,
538 "Failed: bmc150_accel_set_power_state for %d\n", on); 538 "Failed: bmc150_accel_set_power_state for %d\n", on);
539 if (on)
540 pm_runtime_put_noidle(&data->client->dev);
541
539 return ret; 542 return ret;
540 } 543 }
541 544
@@ -811,6 +814,7 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev,
811 814
812 ret = bmc150_accel_setup_any_motion_interrupt(data, state); 815 ret = bmc150_accel_setup_any_motion_interrupt(data, state);
813 if (ret < 0) { 816 if (ret < 0) {
817 bmc150_accel_set_power_state(data, false);
814 mutex_unlock(&data->mutex); 818 mutex_unlock(&data->mutex);
815 return ret; 819 return ret;
816 } 820 }
@@ -1054,6 +1058,7 @@ static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig,
1054 else 1058 else
1055 ret = bmc150_accel_setup_new_data_interrupt(data, state); 1059 ret = bmc150_accel_setup_new_data_interrupt(data, state);
1056 if (ret < 0) { 1060 if (ret < 0) {
1061 bmc150_accel_set_power_state(data, false);
1057 mutex_unlock(&data->mutex); 1062 mutex_unlock(&data->mutex);
1058 return ret; 1063 return ret;
1059 } 1064 }
@@ -1354,10 +1359,14 @@ static int bmc150_accel_runtime_suspend(struct device *dev)
1354{ 1359{
1355 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); 1360 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
1356 struct bmc150_accel_data *data = iio_priv(indio_dev); 1361 struct bmc150_accel_data *data = iio_priv(indio_dev);
1362 int ret;
1357 1363
1358 dev_dbg(&data->client->dev, __func__); 1364 dev_dbg(&data->client->dev, __func__);
1365 ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0);
1366 if (ret < 0)
1367 return -EAGAIN;
1359 1368
1360 return bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0); 1369 return 0;
1361} 1370}
1362 1371
1363static int bmc150_accel_runtime_resume(struct device *dev) 1372static int bmc150_accel_runtime_resume(struct device *dev)