iio: Fix error handling for PM
commit 632fe0bb8c5b9c06ec961f575ee42a6fff5eceeb upstream. The pm_runtime_enable will increase power disable depth. If the probe fails, we should use pm_runtime_disable() to balance pm_runtime_enable(). In the PM Runtime docs: Drivers in ->remove() callback should undo the runtime PM changes done in ->probe(). Usually this means calling pm_runtime_disable(), pm_runtime_dont_use_autosuspend() etc. We should do this in error handling. Fix this problem for the following drivers: bmc150, bmg160, kmx61, kxcj-1013, mma9551, mma9553. Fixes: 7d0ead5c3f00 ("iio: Reconcile operation order between iio_register/unregister and pm functions") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220106112309.16879-1-linmq006@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8fff0310e6
commit
a28f8dbd47
drivers/iio
accel
gyro
imu
magnetometer
@ -1649,11 +1649,14 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Unable to register iio device\n");
|
||||
goto err_trigger_unregister;
|
||||
goto err_pm_cleanup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_pm_cleanup:
|
||||
pm_runtime_dont_use_autosuspend(dev);
|
||||
pm_runtime_disable(dev);
|
||||
err_trigger_unregister:
|
||||
bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1);
|
||||
err_buffer_cleanup:
|
||||
|
@ -1409,11 +1409,14 @@ static int kxcjk1013_probe(struct i2c_client *client,
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "unable to register iio device\n");
|
||||
goto err_buffer_cleanup;
|
||||
goto err_pm_cleanup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_pm_cleanup:
|
||||
pm_runtime_dont_use_autosuspend(&client->dev);
|
||||
pm_runtime_disable(&client->dev);
|
||||
err_buffer_cleanup:
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
err_trigger_unregister:
|
||||
|
@ -496,11 +496,14 @@ static int mma9551_probe(struct i2c_client *client,
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "unable to register iio device\n");
|
||||
goto out_poweroff;
|
||||
goto err_pm_cleanup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_pm_cleanup:
|
||||
pm_runtime_dont_use_autosuspend(&client->dev);
|
||||
pm_runtime_disable(&client->dev);
|
||||
out_poweroff:
|
||||
mma9551_set_device_state(client, false);
|
||||
|
||||
|
@ -1135,12 +1135,15 @@ static int mma9553_probe(struct i2c_client *client,
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "unable to register iio device\n");
|
||||
goto out_poweroff;
|
||||
goto err_pm_cleanup;
|
||||
}
|
||||
|
||||
dev_dbg(&indio_dev->dev, "Registered device %s\n", name);
|
||||
return 0;
|
||||
|
||||
err_pm_cleanup:
|
||||
pm_runtime_dont_use_autosuspend(&client->dev);
|
||||
pm_runtime_disable(&client->dev);
|
||||
out_poweroff:
|
||||
mma9551_set_device_state(client, false);
|
||||
return ret;
|
||||
|
@ -1173,11 +1173,14 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq,
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "unable to register iio device\n");
|
||||
goto err_buffer_cleanup;
|
||||
goto err_pm_cleanup;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_pm_cleanup:
|
||||
pm_runtime_dont_use_autosuspend(dev);
|
||||
pm_runtime_disable(dev);
|
||||
err_buffer_cleanup:
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
err_trigger_unregister:
|
||||
|
@ -1393,7 +1393,7 @@ static int kmx61_probe(struct i2c_client *client,
|
||||
ret = iio_device_register(data->acc_indio_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "Failed to register acc iio device\n");
|
||||
goto err_buffer_cleanup_mag;
|
||||
goto err_pm_cleanup;
|
||||
}
|
||||
|
||||
ret = iio_device_register(data->mag_indio_dev);
|
||||
@ -1406,6 +1406,9 @@ static int kmx61_probe(struct i2c_client *client,
|
||||
|
||||
err_iio_unregister_acc:
|
||||
iio_device_unregister(data->acc_indio_dev);
|
||||
err_pm_cleanup:
|
||||
pm_runtime_dont_use_autosuspend(&client->dev);
|
||||
pm_runtime_disable(&client->dev);
|
||||
err_buffer_cleanup_mag:
|
||||
if (client->irq > 0)
|
||||
iio_triggered_buffer_cleanup(data->mag_indio_dev);
|
||||
|
@ -944,13 +944,14 @@ int bmc150_magn_probe(struct device *dev, struct regmap *regmap,
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "unable to register iio device\n");
|
||||
goto err_disable_runtime_pm;
|
||||
goto err_pm_cleanup;
|
||||
}
|
||||
|
||||
dev_dbg(dev, "Registered device %s\n", name);
|
||||
return 0;
|
||||
|
||||
err_disable_runtime_pm:
|
||||
err_pm_cleanup:
|
||||
pm_runtime_dont_use_autosuspend(dev);
|
||||
pm_runtime_disable(dev);
|
||||
err_buffer_cleanup:
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
|
Loading…
x
Reference in New Issue
Block a user