]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: adc: rzg2l: Cleanup suspend/resume path
authorClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Sun, 10 Aug 2025 12:33:27 +0000 (15:33 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:34:40 +0000 (16:34 +0200)
commit a3c6eabe3bbd6b0e7124d68b2d3bc32fed17362e upstream.

There is no need to manually track the runtime PM status in the driver.
The pm_runtime_force_suspend() and pm_runtime_force_resume() functions
already call pm_runtime_status_suspended() to check the runtime PM state.

Additionally, avoid calling pm_runtime_put_autosuspend() during the
suspend/resume path, as this would decrease the usage counter of a
potential user that had the ADC open before the suspend/resume cycle.

Fixes: 563cf94f9329 ("iio: adc: rzg2l_adc: Add suspend/resume support")
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20250810123328.800104-2-claudiu.beznea.uj@bp.renesas.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/rzg2l_adc.c

index 1fb2d2ddad68bbbd47c6108e6d4855f8e13de55d..cadb0446bc295662b5de55bf3d2f9cc3718af026 100644 (file)
@@ -89,7 +89,6 @@ struct rzg2l_adc {
        struct completion completion;
        struct mutex lock;
        u16 last_val[RZG2L_ADC_MAX_CHANNELS];
-       bool was_rpm_active;
 };
 
 /**
@@ -541,14 +540,9 @@ static int rzg2l_adc_suspend(struct device *dev)
        };
        int ret;
 
-       if (pm_runtime_suspended(dev)) {
-               adc->was_rpm_active = false;
-       } else {
-               ret = pm_runtime_force_suspend(dev);
-               if (ret)
-                       return ret;
-               adc->was_rpm_active = true;
-       }
+       ret = pm_runtime_force_suspend(dev);
+       if (ret)
+               return ret;
 
        ret = reset_control_bulk_assert(ARRAY_SIZE(resets), resets);
        if (ret)
@@ -557,9 +551,7 @@ static int rzg2l_adc_suspend(struct device *dev)
        return 0;
 
 rpm_restore:
-       if (adc->was_rpm_active)
-               pm_runtime_force_resume(dev);
-
+       pm_runtime_force_resume(dev);
        return ret;
 }
 
@@ -577,11 +569,9 @@ static int rzg2l_adc_resume(struct device *dev)
        if (ret)
                return ret;
 
-       if (adc->was_rpm_active) {
-               ret = pm_runtime_force_resume(dev);
-               if (ret)
-                       goto resets_restore;
-       }
+       ret = pm_runtime_force_resume(dev);
+       if (ret)
+               goto resets_restore;
 
        ret = rzg2l_adc_hw_init(dev, adc);
        if (ret)
@@ -590,10 +580,7 @@ static int rzg2l_adc_resume(struct device *dev)
        return 0;
 
 rpm_restore:
-       if (adc->was_rpm_active) {
-               pm_runtime_mark_last_busy(dev);
-               pm_runtime_put_autosuspend(dev);
-       }
+       pm_runtime_force_suspend(dev);
 resets_restore:
        reset_control_bulk_assert(ARRAY_SIZE(resets), resets);
        return ret;