From: Jonathan Cameron Date: Sun, 9 May 2021 11:33:34 +0000 (+0100) Subject: iio: hid: trigger: Balance runtime pm + use pm_runtime_resume_and_get() X-Git-Tag: v5.14-rc1~66^2~180^2~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af51ec8c9213ec502c3f5c9f5860dd98fceb3433;p=thirdparty%2Fkernel%2Flinux.git iio: hid: trigger: Balance runtime pm + use pm_runtime_resume_and_get() The call to pm_runtime_put_noidle() in remove() callback is not balanced by any gets Note this doesn't cause any problems beyond reader confusion as the runtime pm core protects against the reference counter going negative. Whilst here, use pm_runtiem_resume_and_get() to simplify code a little. Signed-off-by: Jonathan Cameron Cc: Srinivas Pandruvada Reviewed-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/20210509113354.660190-9-jic23@kernel.org --- diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index 5a7b3e253e585..c06537e106e98 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c @@ -163,18 +163,15 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state) if (state) { atomic_inc(&st->user_requested_state); - ret = pm_runtime_get_sync(&st->pdev->dev); + ret = pm_runtime_resume_and_get(&st->pdev->dev); } else { atomic_dec(&st->user_requested_state); pm_runtime_mark_last_busy(&st->pdev->dev); pm_runtime_use_autosuspend(&st->pdev->dev); ret = pm_runtime_put_autosuspend(&st->pdev->dev); } - if (ret < 0) { - if (state) - pm_runtime_put_noidle(&st->pdev->dev); + if (ret < 0) return ret; - } return 0; #else @@ -222,7 +219,6 @@ void hid_sensor_remove_trigger(struct iio_dev *indio_dev, pm_runtime_disable(&attrb->pdev->dev); pm_runtime_set_suspended(&attrb->pdev->dev); - pm_runtime_put_noidle(&attrb->pdev->dev); cancel_work_sync(&attrb->work); iio_trigger_unregister(attrb->trigger);