[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5774190.DvuYhMxLoT@steina-w>
Date: Thu, 25 Jan 2024 10:11:54 +0100
From: Alexander Stein <alexander.stein@...tq-group.com>
To: Jassi Brar <jassisinghbrar@...il.com>, Rob Herring <robh+dt@...nel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>, Conor Dooley <conor+dt@...nel.org>, Dong Aisheng <aisheng.dong@....com>, Shawn Guo <shawnguo@...nel.org>, Sascha Hauer <s.hauer@...gutronix.de>, Pengutronix Kernel Team <kernel@...gutronix.de>, Fabio Estevam <festevam@...il.com>, NXP Linux Team <linux-imx@....com>, linux-arm-kernel@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org, devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, Peng Fan <peng.fan@....com>, "Peng Fan (OSS)" <peng.fan@....nxp.com>
Subject: Re: [PATCH v4 2/4] mailbox: imx: support return value of init
Hi Peng,
Am Donnerstag, 25. Januar 2024, 06:20:04 CET schrieb Peng Fan (OSS):
> From: Peng Fan <peng.fan@....com>
>
> There will be changes that init may fail, so adding return value for
> init function.
>
> Signed-off-by: Peng Fan <peng.fan@....com>
> ---
> drivers/mailbox/imx-mailbox.c | 35 ++++++++++++++++++++++++-----------
> 1 file changed, 24 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
> index 656171362fe9..dced4614065f 100644
> --- a/drivers/mailbox/imx-mailbox.c
> +++ b/drivers/mailbox/imx-mailbox.c
> @@ -110,7 +110,7 @@ struct imx_mu_dcfg {
> int (*tx)(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp, void
> *data); int (*rx)(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp);
> int (*rxdb)(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp); - void
> (*init)(struct imx_mu_priv *priv);
> + int (*init)(struct imx_mu_priv *priv);
> enum imx_mu_type type;
> u32 xTR; /* Transmit Register0 */
> u32 xRR; /* Receive Register0 */
> @@ -737,7 +737,7 @@ static struct mbox_chan *imx_mu_seco_xlate(struct
> mbox_controller *mbox, return imx_mu_xlate(mbox, sp);
> }
>
> -static void imx_mu_init_generic(struct imx_mu_priv *priv)
> +static int imx_mu_init_generic(struct imx_mu_priv *priv)
> {
> unsigned int i;
> unsigned int val;
> @@ -757,7 +757,7 @@ static void imx_mu_init_generic(struct imx_mu_priv
> *priv) priv->mbox.of_xlate = imx_mu_xlate;
>
> if (priv->side_b)
> - return;
> + return 0;
>
> /* Set default MU configuration */
> for (i = 0; i < IMX_MU_xCR_MAX; i++)
> @@ -770,9 +770,11 @@ static void imx_mu_init_generic(struct imx_mu_priv
> *priv) /* Clear any pending RSR */
> for (i = 0; i < IMX_MU_NUM_RR; i++)
> imx_mu_read(priv, priv->dcfg->xRR + (i % 4) * 4);
> +
> + return 0;
> }
>
> -static void imx_mu_init_specific(struct imx_mu_priv *priv)
> +static int imx_mu_init_specific(struct imx_mu_priv *priv)
> {
> unsigned int i;
> int num_chans = priv->dcfg->type & IMX_MU_V2_S4 ? IMX_MU_S4_CHANS :
> IMX_MU_SCU_CHANS; @@ -794,12 +796,20 @@ static void
> imx_mu_init_specific(struct imx_mu_priv *priv) /* Set default MU
> configuration */
> for (i = 0; i < IMX_MU_xCR_MAX; i++)
> imx_mu_write(priv, 0, priv->dcfg->xCR[i]);
> +
> + return 0;
> }
>
> -static void imx_mu_init_seco(struct imx_mu_priv *priv)
> +static int imx_mu_init_seco(struct imx_mu_priv *priv)
> {
> - imx_mu_init_generic(priv);
> + int ret;
> +
> + ret = imx_mu_init_generic(priv);
> + if (ret)
> + return ret;
> priv->mbox.of_xlate = imx_mu_seco_xlate;
> +
> + return 0;
> }
>
> static int imx_mu_probe(struct platform_device *pdev)
> @@ -866,7 +876,11 @@ static int imx_mu_probe(struct platform_device *pdev)
>
> priv->side_b = of_property_read_bool(np, "fsl,mu-side-b");
>
> - priv->dcfg->init(priv);
> + ret = priv->dcfg->init(priv);
> + if (ret) {
> + dev_err(dev, "Failed to init MU\n");
As this is during probe, I rather use dev_err_probe right away. Even if dcfg-
>init won't return -EPROBE_DEFER for now.
Best regards,
Alexander
> + goto disable_clk;
> + }
>
> spin_lock_init(&priv->xcr_lock);
>
> @@ -878,10 +892,8 @@ static int imx_mu_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, priv);
>
> ret = devm_mbox_controller_register(dev, &priv->mbox);
> - if (ret) {
> - clk_disable_unprepare(priv->clk);
> - return ret;
> - }
> + if (ret)
> + goto disable_clk;
>
> pm_runtime_enable(dev);
>
> @@ -899,6 +911,7 @@ static int imx_mu_probe(struct platform_device *pdev)
>
> disable_runtime_pm:
> pm_runtime_disable(dev);
> +disable_clk:
> clk_disable_unprepare(priv->clk);
> return ret;
> }
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
Powered by blists - more mailing lists