mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Shawn Sung (宋孝謙)" <Shawn.Sung@mediatek.com>
To: "p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"angelogioacchino.delregno@collabora.com" 
	<angelogioacchino.delregno@collabora.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
	"krzysztof.kozlowski+dt@linaro.org" 
	<krzysztof.kozlowski+dt@linaro.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Singo Chang (張興國)" <Singo.Chang@mediatek.com>,
	"Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v4 12/14] drm/mediatek: Improve compatibility of display driver
Date: Tue, 27 Jun 2023 07:25:50 +0000	[thread overview]
Message-ID: <b9279145425a405ddbac114ff343b5f452c3b0ab.camel@mediatek.com> (raw)
In-Reply-To: <13bd0198-457f-e0fb-89bd-fd6b6954b8b3@collabora.com>

On Wed, 2023-06-21 at 10:15 +0200, AngeloGioacchino Del Regno wrote:
> >     
> > >   
> > > +static int mtk_ovl_adaptor_enable(struct device *dev, enum
> > mtk_ovl_adaptor_comp_type type)
> > > +{
> > > +int ret = 0;
> >
> > int ret;
> >
> > > +
> > > +if (!dev)
> >
> > if (!dev)
> > return -ENODEV;
> >

We intentionally ignored null dev and didn't return error here, since
MT8195 and MT8188 shares the same component list, there could be
components that are not probed and therefore is null here (For
example, the new hardware Padding in MT8188 only).
 
> > > +goto end;
> > > +
> > > +switch (type) {
> > > +case OVL_ADAPTOR_TYPE_ETHDR:
> > > +ret = mtk_ethdr_clk_enable(dev);
> > > +break;
> > > +case OVL_ADAPTOR_TYPE_MERGE:
> > > +ret = mtk_merge_clk_enable(dev);
> >
> > We already have a .clk_enable() callback in struct
> > mtk_ddp_comp_funcs: to
> > greatly enhance your nice cleanup, you could use that instead,
> which
> > basically
> > eliminates the need of having any if branch and/or switch.
> >

Thanks for the advice, submitted a new version using
mtk_ddp_comp_funcs.
 
> > > +break;
> > > +case OVL_ADAPTOR_TYPE_RDMA:
> > > +// only LARB users need to do this
> >
> > Please, C-style comments only.
> >
> > > +ret = pm_runtime_get_sync(dev);
> > > +if (ret < 0) {
> > > +dev_err(dev, "Failed to enable power domain, error(%d)\n", ret);
> > > +goto end;
> > > +}
> > > +ret = mtk_mdp_rdma_clk_enable(dev);
> > > +if (ret)
> > > +pm_runtime_put(dev);
> > > +break;
> > > +default:
> > > +dev_err(dev, "Unknown type: %d\n", type);
> >
> > Are we supposed to return 0 for unknown type?!
> >

Yes, we ignored the unknown type intentionally, but this part has been
removed in the new patch since 'switch' are all removed after re-using
mtk_ddp_comp_funcs.
 
> > >   for (i = 0; i < OVL_ADAPTOR_ID_MAX; i++) {
> > > -comp = ovl_adaptor->ovl_adaptor_comp[i];
> > > -
> > > -if (i < OVL_ADAPTOR_MERGE0)
> > > -ret = mtk_mdp_rdma_clk_enable(comp);
> > > -else if (i < OVL_ADAPTOR_ETHDR0)
> > > -ret = mtk_merge_clk_enable(comp);
> > > -else
> > > -ret = mtk_ethdr_clk_enable(comp);
> > > +ret = mtk_ovl_adaptor_enable(ovl_adaptor->ovl_adaptor_comp[i],
> > > +     comp_matches[i].type);
> > >   if (ret) {
> > > -dev_err(dev, "Failed to enable clock %d, err %d\n", i, ret);
> > > -goto clk_err;
> > > +while (--i >= 0)
> > > +mtk_ovl_adaptor_disable(ovl_adaptor->ovl_adaptor_comp[i],
> > > +comp_matches[i].type);
> > > +break;
> >
> > Instead of a break here, just return ret?

Got it, has submitted a new version that returns the error immediately.
 
The reason we break here instead of returning error, is trying to make
one function only has one return. For example, always return at the end
of a function, so if someday we add a printk() at somewhere in that
function for debugging, it won't be skipped by the 'return' before it.
 
Not sure if this convention is not recommended when writing kernel
codes? Thanks.
 
Regards,
Hsiao Chien Sung
 

  reply	other threads:[~2023-06-27  7:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-21  3:19 [PATCH v4 00/14] Add display driver for MT8188 VDOSYS1 Hsiao Chien Sung
2023-06-21  3:19 ` [PATCH v4 01/14] dt-bindings: display: mediatek: ethdr: Add compatible for MT8188 Hsiao Chien Sung
2023-06-21  3:19 ` [PATCH v4 02/14] dt-bindings: display: mediatek: mdp-rdma: " Hsiao Chien Sung
2023-06-21  3:19 ` [PATCH v4 03/14] dt-bindings: display: mediatek: merge: " Hsiao Chien Sung
2023-06-21  3:19 ` [PATCH v4 04/14] dt-bindings: display: mediatek: padding: Add MT8188 Hsiao Chien Sung
2023-06-21  6:35   ` Krzysztof Kozlowski
2023-06-21  3:19 ` [PATCH v4 05/14] dt-bindings: arm: mediatek: Add compatible for MT8188 Hsiao Chien Sung
2023-06-21  3:19 ` [PATCH v4 06/14] dt-bindings: reset: mt8188: Add VDOSYS reset control bits Hsiao Chien Sung
2023-06-21  6:35   ` Krzysztof Kozlowski
2023-06-21  3:19 ` [PATCH v4 07/14] soc: mediatek: Support MT8188 VDOSYS1 in mtk-mmsys Hsiao Chien Sung
2023-06-21  3:19 ` [PATCH v4 08/14] soc: mediatek: Support MT8188 VDOSYS1 Padding " Hsiao Chien Sung
2023-06-21  3:19 ` [PATCH v4 09/14] soc: mediatek: Support reset bit mapping in mmsys driver Hsiao Chien Sung
2023-06-21  8:06   ` AngeloGioacchino Del Regno
2023-06-21  3:19 ` [PATCH v4 10/14] soc: mediatek: Add MT8188 VDOSYS reset bit map Hsiao Chien Sung
2023-06-21  8:06   ` AngeloGioacchino Del Regno
2023-06-21  3:19 ` [PATCH v4 11/14] drm/mediatek: Support MT8188 VDOSYS1 in display driver Hsiao Chien Sung
2023-06-21  3:19 ` [PATCH v4 12/14] drm/mediatek: Improve compatibility of " Hsiao Chien Sung
2023-06-21  8:15   ` AngeloGioacchino Del Regno
2023-06-27  7:25     ` Shawn Sung (宋孝謙) [this message]
2023-06-21  3:19 ` [PATCH v4 13/14] drm/mediatek: Sort OVL adaptor components in alphabetical order Hsiao Chien Sung
2023-06-21  8:16   ` AngeloGioacchino Del Regno
2023-06-21  9:16     ` Shawn Sung (宋孝謙)
2023-06-21 10:00       ` AngeloGioacchino Del Regno
2023-06-21  3:19 ` [PATCH v4 14/14] drm/mediatek: Support MT8188 Padding in display driver Hsiao Chien Sung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9279145425a405ddbac114ff343b5f452c3b0ab.camel@mediatek.com \
    --to=shawn.sung@mediatek.com \
    --cc=Jason-JH.Lin@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Singo.Chang@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®