OSDN Git Service

media: ti-vpe: use pm_runtime_resume_and_get()
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 23 Apr 2021 15:19:21 +0000 (17:19 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 20 May 2021 14:02:44 +0000 (16:02 +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.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/ti-vpe/cal-video.c
drivers/media/platform/ti-vpe/cal.c
drivers/media/platform/ti-vpe/vpe.c

index 7b7436a..15fb536 100644 (file)
@@ -700,7 +700,9 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
 
        addr = vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0);
 
-       pm_runtime_get_sync(ctx->cal->dev);
+       ret = pm_runtime_resume_and_get(ctx->cal->dev);
+       if (ret < 0)
+               goto error_pipeline;
 
        cal_ctx_set_dma_addr(ctx, addr);
        cal_ctx_start(ctx);
index 2e2bef9..76fe7a8 100644 (file)
@@ -1024,7 +1024,7 @@ static int cal_probe(struct platform_device *pdev)
 
        /* Read the revision and hardware info to verify hardware access. */
        pm_runtime_enable(&pdev->dev);
-       ret = pm_runtime_get_sync(&pdev->dev);
+       ret = pm_runtime_resume_and_get(&pdev->dev);
        if (ret)
                goto error_pm_runtime;
 
@@ -1098,10 +1098,11 @@ static int cal_remove(struct platform_device *pdev)
 {
        struct cal_dev *cal = platform_get_drvdata(pdev);
        unsigned int i;
+       int ret;
 
        cal_dbg(1, cal, "Removing %s\n", CAL_MODULE_NAME);
 
-       pm_runtime_get_sync(&pdev->dev);
+       ret = pm_runtime_resume_and_get(&pdev->dev);
 
        cal_media_unregister(cal);
 
@@ -1115,7 +1116,8 @@ static int cal_remove(struct platform_device *pdev)
        for (i = 0; i < cal->data->num_csi2_phy; i++)
                cal_camerarx_destroy(cal->phy[i]);
 
-       pm_runtime_put_sync(&pdev->dev);
+       if (ret >= 0)
+               pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
 
        return 0;
index 10251b7..5b1c5d9 100644 (file)
@@ -2471,11 +2471,9 @@ static int vpe_runtime_get(struct platform_device *pdev)
 
        dev_dbg(&pdev->dev, "vpe_runtime_get\n");
 
-       r = pm_runtime_get_sync(&pdev->dev);
+       r = pm_runtime_resume_and_get(&pdev->dev);
        WARN_ON(r < 0);
-       if (r)
-               pm_runtime_put_noidle(&pdev->dev);
-       return r < 0 ? r : 0;
+       return r;
 }
 
 static void vpe_runtime_put(struct platform_device *pdev)
@@ -2580,7 +2578,7 @@ static int vpe_probe(struct platform_device *pdev)
        pm_runtime_enable(&pdev->dev);
 
        ret = vpe_runtime_get(pdev);
-       if (ret)
+       if (ret < 0)
                goto rel_m2m;
 
        /* Perform clk enable followed by reset */