[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <00e0af22e3913a0e20cc3e00d78fbbf9098a5fa6.camel@mediatek.com>
Date: Fri, 7 Feb 2025 06:26:54 +0000
From: CK Hu (胡俊光) <ck.hu@...iatek.com>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
"chunkuang.hu@...nel.org" <chunkuang.hu@...nel.org>
CC: "robh@...nel.org" <robh@...nel.org>, "jie.qiu@...iatek.com"
<jie.qiu@...iatek.com>, "tzimmermann@...e.de" <tzimmermann@...e.de>,
"simona@...ll.ch" <simona@...ll.ch>, "mripard@...nel.org"
<mripard@...nel.org>, Jitao Shi (石记涛)
<jitao.shi@...iatek.com>, "linux-mediatek@...ts.infradead.org"
<linux-mediatek@...ts.infradead.org>, "dri-devel@...ts.freedesktop.org"
<dri-devel@...ts.freedesktop.org>, "maarten.lankhorst@...ux.intel.com"
<maarten.lankhorst@...ux.intel.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "devicetree@...r.kernel.org"
<devicetree@...r.kernel.org>, "kernel@...labora.com" <kernel@...labora.com>,
"dmitry.baryshkov@...aro.org" <dmitry.baryshkov@...aro.org>,
"krzk+dt@...nel.org" <krzk+dt@...nel.org>,
Lewis Liao (廖柏鈞) <Lewis.Liao@...iatek.com>,
"p.zabel@...gutronix.de" <p.zabel@...gutronix.de>, "conor+dt@...nel.org"
<conor+dt@...nel.org>, TommyYL Chen (陳彥良)
<TommyYL.Chen@...iatek.com>, Ives Chenjh (陳俊弘)
<Ives.Chenjh@...iatek.com>, "airlied@...il.com" <airlied@...il.com>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "matthias.bgg@...il.com"
<matthias.bgg@...il.com>, Jason-JH Lin (林睿祥)
<Jason-JH.Lin@...iatek.com>, "junzhi.zhao@...iatek.com"
<junzhi.zhao@...iatek.com>
Subject: Re: [PATCH v5 28/34] drm/mediatek: mtk_hdmi: Improve
mtk_hdmi_get_all_clk() flexibility
Hi, Angelo:
On Mon, 2025-01-13 at 15:52 +0100, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
>
>
> In preparation for splitting common bits of this driver and for
> introducing a new version of the MediaTek HDMI Encoder IP, improve
> the flexibility of function mtk_hdmi_get_all_clk() by adding a
> pointer to the clock names array and size of it to its parameters.
>
> Also change the array of struct clock pointers in the mtk_hdmi
> structure to be dynamically allocated, and allocate it in probe.
Reviewed-by: CK Hu <ck.hu@...iatek.com>
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
> ---
> drivers/gpu/drm/mediatek/mtk_hdmi.c | 26 ++++++++++++++++----------
> 1 file changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> index c5431f160fe4..138c6283c038 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> @@ -159,7 +159,7 @@ struct mtk_hdmi {
> struct phy *phy;
> struct device *cec_dev;
> struct i2c_adapter *ddc_adpt;
> - struct clk *clk[MTK_HDMI_CLK_COUNT];
> + struct clk **clk;
> struct drm_display_mode mode;
> bool dvi_mode;
> struct regmap *sys_regmap;
> @@ -1072,17 +1072,18 @@ static const char * const mtk_hdmi_clk_names[MTK_HDMI_CLK_COUNT] = {
> [MTK_HDMI_CLK_AUD_SPDIF] = "spdif",
> };
>
> -static int mtk_hdmi_get_all_clk(struct mtk_hdmi *hdmi,
> - struct device_node *np)
> +static int mtk_hdmi_get_all_clk(struct mtk_hdmi *hdmi, struct device_node *np,
> + const char * const *clock_names, size_t num_clocks)
> {
> int i;
>
> - for (i = 0; i < ARRAY_SIZE(mtk_hdmi_clk_names); i++) {
> - hdmi->clk[i] = of_clk_get_by_name(np,
> - mtk_hdmi_clk_names[i]);
> + for (i = 0; i < num_clocks; i++) {
> + hdmi->clk[i] = of_clk_get_by_name(np, clock_names[i]);
> +
> if (IS_ERR(hdmi->clk[i]))
> return PTR_ERR(hdmi->clk[i]);
> }
> +
> return 0;
> }
>
> @@ -1381,15 +1382,15 @@ static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struc
> return 0;
> }
>
> -static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
> - struct platform_device *pdev)
> +static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, struct platform_device *pdev,
> + const char * const *clk_names, size_t num_clocks)
> {
> struct device *dev = &pdev->dev;
> struct device_node *np = dev->of_node;
> struct device_node *remote, *i2c_np;
> int ret;
>
> - ret = mtk_hdmi_get_all_clk(hdmi, np);
> + ret = mtk_hdmi_get_all_clk(hdmi, np, clk_names, num_clocks);
> if (ret)
> return dev_err_probe(dev, ret, "Failed to get clocks\n");
>
> @@ -1638,6 +1639,7 @@ static int mtk_hdmi_probe(struct platform_device *pdev)
> {
> struct mtk_hdmi *hdmi;
> struct device *dev = &pdev->dev;
> + const int num_clocks = MTK_HDMI_CLK_COUNT;
> int ret;
>
> hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
> @@ -1647,7 +1649,11 @@ static int mtk_hdmi_probe(struct platform_device *pdev)
> hdmi->dev = dev;
> hdmi->conf = of_device_get_match_data(dev);
>
> - ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev);
> + hdmi->clk = devm_kcalloc(dev, num_clocks, sizeof(*hdmi->clk), GFP_KERNEL);
> + if (!hdmi->clk)
> + return -ENOMEM;
> +
> + ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev, mtk_hdmi_clk_names, num_clocks);
> if (ret)
> return ret;
>
> --
> 2.47.0
>
Powered by blists - more mailing lists