aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2014-10-10 23:33:25 -0400
committerJonathan Cameron <jic23@kernel.org>2014-11-16 15:19:18 -0500
commit10bef28973071266e85fe7ea50e08ce8f46dc1ca (patch)
tree9483de9f791c8cf41bd86b5770af350f966bf801 /drivers/iio
parentfbbba1f89eb68e7d07707e104193d56de8e37fe5 (diff)
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: 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/gyro/bmg160.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
index 1f967e0d688e..22bf9db538b3 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160.c
@@ -250,6 +250,9 @@ static int bmg160_set_power_state(struct bmg160_data *data, bool on)
250 if (ret < 0) { 250 if (ret < 0) {
251 dev_err(&data->client->dev, 251 dev_err(&data->client->dev,
252 "Failed: bmg160_set_power_state for %d\n", on); 252 "Failed: bmg160_set_power_state for %d\n", on);
253 if (on)
254 pm_runtime_put_noidle(&data->client->dev);
255
253 return ret; 256 return ret;
254 } 257 }
255#endif 258#endif
@@ -705,6 +708,7 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev,
705 708
706 ret = bmg160_setup_any_motion_interrupt(data, state); 709 ret = bmg160_setup_any_motion_interrupt(data, state);
707 if (ret < 0) { 710 if (ret < 0) {
711 bmg160_set_power_state(data, false);
708 mutex_unlock(&data->mutex); 712 mutex_unlock(&data->mutex);
709 return ret; 713 return ret;
710 } 714 }
@@ -871,6 +875,7 @@ static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig,
871 else 875 else
872 ret = bmg160_setup_new_data_interrupt(data, state); 876 ret = bmg160_setup_new_data_interrupt(data, state);
873 if (ret < 0) { 877 if (ret < 0) {
878 bmg160_set_power_state(data, false);
874 mutex_unlock(&data->mutex); 879 mutex_unlock(&data->mutex);
875 return ret; 880 return ret;
876 } 881 }
@@ -1169,8 +1174,15 @@ static int bmg160_runtime_suspend(struct device *dev)
1169{ 1174{
1170 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); 1175 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
1171 struct bmg160_data *data = iio_priv(indio_dev); 1176 struct bmg160_data *data = iio_priv(indio_dev);
1177 int ret;
1172 1178
1173 return bmg160_set_mode(data, BMG160_MODE_SUSPEND); 1179 ret = bmg160_set_mode(data, BMG160_MODE_SUSPEND);
1180 if (ret < 0) {
1181 dev_err(&data->client->dev, "set mode failed\n");
1182 return -EAGAIN;
1183 }
1184
1185 return 0;
1174} 1186}
1175 1187
1176static int bmg160_runtime_resume(struct device *dev) 1188static int bmg160_runtime_resume(struct device *dev)