[COMMON] media: smfc: return error if error found in .device_run()
authorCho KyongHo <pullip.cho@samsung.com>
Mon, 4 May 2015 07:06:30 +0000 (16:06 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:22:18 +0000 (20:22 +0300)
There may be an error during pm_runtime_get() or clk_enable(). In that
situation, the driver should handle the exceptional cases.

Change-Id: If2ad5fc261eeb3e957a9abfeecac26fe66478d80
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/media/platform/exynos/smfc/smfc.c

index 4bb754d8c0d2d02af0550a4f420224d9a24f6dee..1708c9d215db19b54a76b9d2e1fcb64c9dbd7e5d 100644 (file)
@@ -1152,7 +1152,7 @@ static void smfc_m2m_device_run(void *priv)
                         pm_runtime_get_sync(ctx->smfc->dev);
        if (ret < 0) {
                pr_err("Failed to enable power\n");
-               /* TODO: error current frame */
+               goto err_pm;
        }
 
        if (!IS_ERR(ctx->smfc->clk_gate)) {
@@ -1166,8 +1166,7 @@ static void smfc_m2m_device_run(void *priv)
 
        if (ret < 0) {
                dev_err(ctx->smfc->dev, "Failed to enable clocks\n");
-               pm_runtime_put(ctx->smfc->dev);
-               /* TODO: error current frame */
+               goto err_clk;
        }
 
        smfc_hwconfigure_reset(ctx->smfc);
@@ -1184,6 +1183,21 @@ static void smfc_m2m_device_run(void *priv)
        spin_lock_irqsave(&ctx->smfc->flag_lock, flags);
        ctx->smfc->flags |= SMFC_DEV_RUNNING;
        spin_unlock_irqrestore(&ctx->smfc->flag_lock, flags);
+
+       return;
+
+err_clk:
+       pm_runtime_put(ctx->smfc->dev);
+err_pm:
+       v4l2_m2m_buf_done(
+               v4l2_m2m_src_buf_remove(ctx->m2mctx), VB2_BUF_STATE_ERROR);
+       v4l2_m2m_buf_done(
+               v4l2_m2m_dst_buf_remove(ctx->m2mctx), VB2_BUF_STATE_ERROR);
+       /*
+        * It is safe to call v4l2_m2m_job_finish() here because .device_run()
+        * is called without any lock held
+        */
+       v4l2_m2m_job_finish(ctx->smfc->m2mdev, ctx->m2mctx);
 }
 
 static void smfc_m2m_job_abort(void *priv)