[PATCH v1 2/2] media: platform: mtk-mdp3: fix error handling about components clock_on
AngeloGioacchino Del Regno
angelogioacchino.delregno at collabora.com
Fri Sep 30 05:12:51 PDT 2022
Il 30/09/22 12:23, Moudy Ho ha scritto:
> Add goto statement in mdp_comp_clock_on() to avoid error code not being
> propagated or returning positive values.
> This change also performs a well-timed clock_off when an error occurs, and
> reduces unnecessary error logging in mdp_cmdq_send().
>
> Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 driver")
> Signed-off-by: Moudy Ho <moudy.ho at mediatek.com>
> ---
> .../platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 4 +---
> .../platform/mediatek/mdp3/mtk-mdp3-comp.c | 24 ++++++++++++++-----
> 2 files changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
> index e194dec8050a..124c1b96e96b 100644
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
> @@ -433,10 +433,8 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)
> cmd->mdp_ctx = param->mdp_ctx;
>
> ret = mdp_comp_clocks_on(&mdp->pdev->dev, cmd->comps, cmd->num_comps);
> - if (ret) {
> - dev_err(dev, "comp %d failed to enable clock!\n", ret);
> + if (ret)
> goto err_free_path;
> - }
>
> dma_sync_single_for_device(mdp->cmdq_clt->chan->mbox->dev,
> cmd->pkt.pa_base, cmd->pkt.cmd_buf_size,
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> index d3eaf8884412..fe6a39315e88 100644
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
> @@ -699,12 +699,22 @@ int mdp_comp_clock_on(struct device *dev, struct mdp_comp *comp)
> dev_err(dev,
> "Failed to enable clk %d. type:%d id:%d\n",
> i, comp->type, comp->id);
> - pm_runtime_put(comp->comp_dev);
> - return ret;
> + goto err_unwind;
> }
> }
>
> return 0;
> +
> +err_unwind:
For this label to be clearer, I would rename it as `err_revert`, or
`clocks_off`, or even simply `err`, as the `unwind` word may create
some confusion here.
> + while (--i >= 0) {
> + if (IS_ERR_OR_NULL(comp->clks[i]))
> + continue;
> + clk_disable_unprepare(comp->clks[i]);
> + }
> + if (comp->comp_dev)
> + pm_runtime_put_sync(comp->comp_dev);
> +
> + return ret;
> }
>
> void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp)
> @@ -723,11 +733,13 @@ void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp)
>
> int mdp_comp_clocks_on(struct device *dev, struct mdp_comp *comps, int num)
> {
> - int i;
> + int i, ret;
>
> - for (i = 0; i < num; i++)
> - if (mdp_comp_clock_on(dev, &comps[i]) != 0)
> - return ++i;
> + for (i = 0; i < num; i++) {
> + ret = mdp_comp_clock_on(dev, &comps[i]);
> + if (ret)
> + return ret;
> + }
>
> return 0;
> }
>
More information about the Linux-mediatek
mailing list