public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] iio: accel: bmc150: Error handling when mode set fails
@ 2014-10-10 16:30 Srinivas Pandruvada
  2014-10-10 16:30 ` [PATCH 2/3] iio: accel: bmc150: Send x, y and z motion separately Srinivas Pandruvada
  2014-10-10 16:30 ` [PATCH 3/3] iio: accel: bmc150: set low default thresholds Srinivas Pandruvada
  0 siblings, 2 replies; 5+ messages in thread
From: Srinivas Pandruvada @ 2014-10-10 16:30 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, Srinivas Pandruvada

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>
---
 drivers/iio/accel/bmc150-accel.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index 22c096c..fdb101c 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)
 	if (ret < 0) {
 		dev_err(&data->client->dev,
 			"Failed: bmc150_accel_set_power_state for %d\n", on);
+		if (on)
+			pm_runtime_put_noidle(&data->client->dev);
+
 		return ret;
 	}
 
@@ -811,6 +814,7 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev,
 
 	ret =  bmc150_accel_setup_any_motion_interrupt(data, state);
 	if (ret < 0) {
+		bmc150_accel_set_power_state(data, false);
 		mutex_unlock(&data->mutex);
 		return ret;
 	}
@@ -1054,6 +1058,7 @@ static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig,
 	else
 		ret = bmc150_accel_setup_new_data_interrupt(data, state);
 	if (ret < 0) {
+		bmc150_accel_set_power_state(data, false);
 		mutex_unlock(&data->mutex);
 		return ret;
 	}
@@ -1354,10 +1359,14 @@ static int bmc150_accel_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct bmc150_accel_data *data = iio_priv(indio_dev);
+	int ret;
 
 	dev_dbg(&data->client->dev,  __func__);
+	ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0);
+	if (ret < 0)
+		return -EAGAIN;
 
-	return bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0);
+	return 0;
 }
 
 static int bmc150_accel_runtime_resume(struct device *dev)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-18 17:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-10 16:30 [PATCH 1/3] iio: accel: bmc150: Error handling when mode set fails Srinivas Pandruvada
2014-10-10 16:30 ` [PATCH 2/3] iio: accel: bmc150: Send x, y and z motion separately Srinivas Pandruvada
2014-10-18 12:11   ` Jonathan Cameron
2014-10-18 17:32     ` Srinivas Pandruvada
2014-10-10 16:30 ` [PATCH 3/3] iio: accel: bmc150: set low default thresholds Srinivas Pandruvada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox