diff options
author | Adriana Reus <adriana.reus@intel.com> | 2015-11-05 17:25:29 +0300 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-11-08 18:36:53 +0300 |
commit | 7d0ead5c3f00a0652fa4436f0d2dd05e9f2de140 (patch) | |
tree | 484cd7c138d031fa88e176bf523aaad36c6cb518 /drivers/iio/accel/mma9551.c | |
parent | 536bbca7cfc9e7a85704de552fcf4b5d1062a38e (diff) | |
download | linux-7d0ead5c3f00a0652fa4436f0d2dd05e9f2de140.tar.xz |
iio: Reconcile operation order between iio_register/unregister and pm functions
At probe, runtime pm should be setup before registering the sysfs interface so
that all the power attributes are accurate and functional when registering.
Also, when removing the device we should unregister first to make sure
that the interfaces that may result in wakeups are no longer available.
Fix this behaviour for the following drivers: bmc150, bmg160, kmx61,
kxcj-1013, mma9551, mma9553, rpr0521.
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/accel/mma9551.c')
-rw-r--r-- | drivers/iio/accel/mma9551.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c index 7db7cc0bf362..d899a4d4307f 100644 --- a/drivers/iio/accel/mma9551.c +++ b/drivers/iio/accel/mma9551.c @@ -495,25 +495,23 @@ static int mma9551_probe(struct i2c_client *client, if (ret < 0) goto out_poweroff; - ret = iio_device_register(indio_dev); - if (ret < 0) { - dev_err(&client->dev, "unable to register iio device\n"); - goto out_poweroff; - } - ret = pm_runtime_set_active(&client->dev); if (ret < 0) - goto out_iio_unregister; + goto out_poweroff; pm_runtime_enable(&client->dev); pm_runtime_set_autosuspend_delay(&client->dev, MMA9551_AUTO_SUSPEND_DELAY_MS); pm_runtime_use_autosuspend(&client->dev); + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&client->dev, "unable to register iio device\n"); + goto out_poweroff; + } + return 0; -out_iio_unregister: - iio_device_unregister(indio_dev); out_poweroff: mma9551_set_device_state(client, false); @@ -525,11 +523,12 @@ static int mma9551_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct mma9551_data *data = iio_priv(indio_dev); + iio_device_unregister(indio_dev); + pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); pm_runtime_put_noidle(&client->dev); - iio_device_unregister(indio_dev); mutex_lock(&data->mutex); mma9551_set_device_state(data->client, false); mutex_unlock(&data->mutex); |