mirror of https://gitee.com/openkylin/linux.git
iio: imu: mpu6050: Balance runtime pm + use pm_runtime_resume_and_get()
Remove an unblanced pm_runtime_put_sync_suspend() call in inv_pu_pm_disable(). Not this call is not a bug, because the runtime pm core will not allow the reference counter to go negative. It is however confusing and serves no purpose. pm_runtime_resume_and_get() case found using coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ pm_runtime_resume_and_get() returns <= 0 only so simplify related checks to bring this more inline with nearby calls. This is a prequel to taking a closer look at the runtime pm in IIO drivers in general. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/20210516162103.1332291-2-jic23@kernel.org
This commit is contained in:
parent
12f13d1fae
commit
40b54cbebf
|
@ -570,11 +570,9 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
|
||||||
freq_hz = INV_MPU6050_DIVIDER_TO_FIFO_RATE(st->chip_config.divider);
|
freq_hz = INV_MPU6050_DIVIDER_TO_FIFO_RATE(st->chip_config.divider);
|
||||||
period_us = 1000000 / freq_hz;
|
period_us = 1000000 / freq_hz;
|
||||||
|
|
||||||
result = pm_runtime_get_sync(pdev);
|
result = pm_runtime_resume_and_get(pdev);
|
||||||
if (result < 0) {
|
if (result)
|
||||||
pm_runtime_put_noidle(pdev);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
switch (chan->type) {
|
switch (chan->type) {
|
||||||
case IIO_ANGL_VEL:
|
case IIO_ANGL_VEL:
|
||||||
|
@ -812,11 +810,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
mutex_lock(&st->lock);
|
mutex_lock(&st->lock);
|
||||||
result = pm_runtime_get_sync(pdev);
|
result = pm_runtime_resume_and_get(pdev);
|
||||||
if (result < 0) {
|
if (result)
|
||||||
pm_runtime_put_noidle(pdev);
|
|
||||||
goto error_write_raw_unlock;
|
goto error_write_raw_unlock;
|
||||||
}
|
|
||||||
|
|
||||||
switch (mask) {
|
switch (mask) {
|
||||||
case IIO_CHAN_INFO_SCALE:
|
case IIO_CHAN_INFO_SCALE:
|
||||||
|
@ -930,11 +926,9 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr,
|
||||||
result = 0;
|
result = 0;
|
||||||
goto fifo_rate_fail_unlock;
|
goto fifo_rate_fail_unlock;
|
||||||
}
|
}
|
||||||
result = pm_runtime_get_sync(pdev);
|
result = pm_runtime_resume_and_get(pdev);
|
||||||
if (result < 0) {
|
if (result)
|
||||||
pm_runtime_put_noidle(pdev);
|
|
||||||
goto fifo_rate_fail_unlock;
|
goto fifo_rate_fail_unlock;
|
||||||
}
|
|
||||||
|
|
||||||
result = regmap_write(st->map, st->reg->sample_rate_div, d);
|
result = regmap_write(st->map, st->reg->sample_rate_div, d);
|
||||||
if (result)
|
if (result)
|
||||||
|
@ -1421,7 +1415,6 @@ static void inv_mpu_pm_disable(void *data)
|
||||||
{
|
{
|
||||||
struct device *dev = data;
|
struct device *dev = data;
|
||||||
|
|
||||||
pm_runtime_put_sync_suspend(dev);
|
|
||||||
pm_runtime_disable(dev);
|
pm_runtime_disable(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,11 +173,9 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable)
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
scan = inv_scan_query(indio_dev);
|
scan = inv_scan_query(indio_dev);
|
||||||
result = pm_runtime_get_sync(pdev);
|
result = pm_runtime_resume_and_get(pdev);
|
||||||
if (result < 0) {
|
if (result)
|
||||||
pm_runtime_put_noidle(pdev);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* In case autosuspend didn't trigger, turn off first not
|
* In case autosuspend didn't trigger, turn off first not
|
||||||
* required sensors.
|
* required sensors.
|
||||||
|
|
Loading…
Reference in New Issue