media: camss: use pm_runtime_resume_and_get()
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 23 Apr 2021 15:19:18 +0000 (17:19 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 19 May 2021 07:51:42 +0000 (09:51 +0200)
Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/qcom/camss/camss-csid.c
drivers/media/platform/qcom/camss/camss-csiphy.c
drivers/media/platform/qcom/camss/camss-ispif.c
drivers/media/platform/qcom/camss/camss-vfe.c

index 0e6b76e..7e2490c 100644 (file)
@@ -156,11 +156,9 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
        int ret;
 
        if (on) {
-               ret = pm_runtime_get_sync(dev);
-               if (ret < 0) {
-                       pm_runtime_put_sync(dev);
+               ret = pm_runtime_resume_and_get(dev);
+               if (ret < 0)
                        return ret;
-               }
 
                ret = regulator_enable(csid->vdda);
                if (ret < 0) {
index 1996541..b623e00 100644 (file)
@@ -197,11 +197,9 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on)
        if (on) {
                int ret;
 
-               ret = pm_runtime_get_sync(dev);
-               if (ret < 0) {
-                       pm_runtime_put_sync(dev);
+               ret = pm_runtime_resume_and_get(dev);
+               if (ret < 0)
                        return ret;
-               }
 
                ret = csiphy_set_clock_rates(csiphy);
                if (ret < 0) {
index d7942f7..1b71618 100644 (file)
@@ -372,11 +372,9 @@ static int ispif_set_power(struct v4l2_subdev *sd, int on)
                        goto exit;
                }
 
-               ret = pm_runtime_get_sync(dev);
-               if (ret < 0) {
-                       pm_runtime_put_sync(dev);
+               ret = pm_runtime_resume_and_get(dev);
+               if (ret < 0)
                        goto exit;
-               }
 
                ret = camss_enable_clocks(ispif->nclocks, ispif->clock, dev);
                if (ret < 0) {
index 1584ee7..27ab20c 100644 (file)
@@ -584,9 +584,9 @@ static int vfe_get(struct vfe_device *vfe)
                if (ret < 0)
                        goto error_pm_domain;
 
-               ret = pm_runtime_get_sync(vfe->camss->dev);
+               ret = pm_runtime_resume_and_get(vfe->camss->dev);
                if (ret < 0)
-                       goto error_pm_runtime_get;
+                       goto error_domain_off;
 
                ret = vfe_set_clock_rates(vfe);
                if (ret < 0)
@@ -620,6 +620,7 @@ error_reset:
 
 error_pm_runtime_get:
        pm_runtime_put_sync(vfe->camss->dev);
+error_domain_off:
        vfe->ops->pm_domain_off(vfe);
 
 error_pm_domain: