diff options
author | Irina Tirdea | 2014-12-10 18:23:53 +0200 |
---|---|---|
committer | Jonathan Cameron | 2014-12-12 12:28:35 +0000 |
commit | fbd123e913ed25ec861ce3be10725b5beb27ab48 (patch) | |
tree | 284b0e690424904ad4dc5c43b130b69b0fcf2eb7 /drivers/iio/accel | |
parent | 374956600ecbedf5ca29c76bde114160eb805091 (diff) |
iio: accel: kxcjk-1013: error handling when set mode fails
If there is an error in set mode at runtime resume, reset the state of
the runtime usage count.
If there is an error in set mode at runtime suspend, make sure the framework
retries to suspend the device.
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/accel')
-rw-r--r-- | drivers/iio/accel/kxcjk-1013.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 7b0a9dac7ae3..0dc6ccfbee46 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -388,6 +388,8 @@ static int kxcjk1013_set_power_state(struct kxcjk1013_data *data, bool on) if (ret < 0) { dev_err(&data->client->dev, "Failed: kxcjk1013_set_power_state for %d\n", on); + if (on) + pm_runtime_put_noidle(&data->client->dev); return ret; } #endif @@ -859,6 +861,8 @@ static int kxcjk1013_write_event_config(struct iio_dev *indio_dev, ret = kxcjk1013_setup_any_motion_interrupt(data, state); if (ret < 0) { + kxcjk1013_set_power_state(data, false); + data->ev_enable_state = 0; mutex_unlock(&data->mutex); return ret; } @@ -1009,6 +1013,7 @@ static int kxcjk1013_data_rdy_trigger_set_state(struct iio_trigger *trig, else ret = kxcjk1013_setup_new_data_interrupt(data, state); if (ret < 0) { + kxcjk1013_set_power_state(data, false); mutex_unlock(&data->mutex); return ret; } @@ -1368,8 +1373,14 @@ static int kxcjk1013_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct kxcjk1013_data *data = iio_priv(indio_dev); + int ret; - return kxcjk1013_set_mode(data, STANDBY); + ret = kxcjk1013_set_mode(data, STANDBY); + if (ret < 0) { + dev_err(&data->client->dev, "powering off device failed\n"); + return -EAGAIN; + } + return 0; } static int kxcjk1013_runtime_resume(struct device *dev) |