From: Frank Li <Frank.li@nxp.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: "Przemysław Gaj" <pgaj@cadence.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i3c: master: cdns: Simplify handling clocks in probe()
Date: Mon, 14 Jul 2025 10:15:08 -0400 [thread overview]
Message-ID: <aHUQ7Ge97/glY+s7@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250713152411.74917-2-krzysztof.kozlowski@linaro.org>
On Sun, Jul 13, 2025 at 05:24:12PM +0200, Krzysztof Kozlowski wrote:
> The two clocks, driver is getting, are not being disabled/re-enabled
> during runtime of the device. Eliminate one variable in state struct,
> all error paths and a lot of code from probe() and remove() by using
> devm_clk_get_enabled().
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> drivers/i3c/master/i3c-master-cdns.c | 51 +++++++---------------------
> 1 file changed, 12 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c
> index 449e85d7ba87..cc504b58013a 100644
> --- a/drivers/i3c/master/i3c-master-cdns.c
> +++ b/drivers/i3c/master/i3c-master-cdns.c
> @@ -412,7 +412,6 @@ struct cdns_i3c_master {
> } xferqueue;
> void __iomem *regs;
> struct clk *sysclk;
> - struct clk *pclk;
> struct cdns_i3c_master_caps caps;
> unsigned long i3c_scl_lim;
> const struct cdns_i3c_data *devdata;
> @@ -1566,6 +1565,7 @@ MODULE_DEVICE_TABLE(of, cdns_i3c_master_of_ids);
> static int cdns_i3c_master_probe(struct platform_device *pdev)
> {
> struct cdns_i3c_master *master;
> + struct clk *pclk;
> int ret, irq;
> u32 val;
>
> @@ -1581,11 +1581,11 @@ static int cdns_i3c_master_probe(struct platform_device *pdev)
> if (IS_ERR(master->regs))
> return PTR_ERR(master->regs);
>
> - master->pclk = devm_clk_get(&pdev->dev, "pclk");
> - if (IS_ERR(master->pclk))
> - return PTR_ERR(master->pclk);
> + pclk = devm_clk_get_enabled(&pdev->dev, "pclk");
> + if (IS_ERR(pclk))
> + return PTR_ERR(pclk);
>
> - master->sysclk = devm_clk_get(&pdev->dev, "sysclk");
> + master->sysclk = devm_clk_get_enabled(&pdev->dev, "sysclk");
Can you use devm_clk_bulk_get_all_enabled() to simpilfy futher?
Frank
> if (IS_ERR(master->sysclk))
> return PTR_ERR(master->sysclk);
>
> @@ -1593,18 +1593,8 @@ static int cdns_i3c_master_probe(struct platform_device *pdev)
> if (irq < 0)
> return irq;
>
> - ret = clk_prepare_enable(master->pclk);
> - if (ret)
> - return ret;
> -
> - ret = clk_prepare_enable(master->sysclk);
> - if (ret)
> - goto err_disable_pclk;
> -
> - if (readl(master->regs + DEV_ID) != DEV_ID_I3C_MASTER) {
> - ret = -EINVAL;
> - goto err_disable_sysclk;
> - }
> + if (readl(master->regs + DEV_ID) != DEV_ID_I3C_MASTER)
> + return -EINVAL;
>
> spin_lock_init(&master->xferqueue.lock);
> INIT_LIST_HEAD(&master->xferqueue.list);
> @@ -1615,7 +1605,7 @@ static int cdns_i3c_master_probe(struct platform_device *pdev)
> ret = devm_request_irq(&pdev->dev, irq, cdns_i3c_master_interrupt, 0,
> dev_name(&pdev->dev), master);
> if (ret)
> - goto err_disable_sysclk;
> + return ret;
>
> platform_set_drvdata(pdev, master);
>
> @@ -1637,29 +1627,15 @@ static int cdns_i3c_master_probe(struct platform_device *pdev)
> master->ibi.slots = devm_kcalloc(&pdev->dev, master->ibi.num_slots,
> sizeof(*master->ibi.slots),
> GFP_KERNEL);
> - if (!master->ibi.slots) {
> - ret = -ENOMEM;
> - goto err_disable_sysclk;
> - }
> + if (!master->ibi.slots)
> + return -ENOMEM;
>
> writel(IBIR_THR(1), master->regs + CMD_IBI_THR_CTRL);
> writel(MST_INT_IBIR_THR, master->regs + MST_IER);
> writel(DEVS_CTRL_DEV_CLR_ALL, master->regs + DEVS_CTRL);
>
> - ret = i3c_master_register(&master->base, &pdev->dev,
> - &cdns_i3c_master_ops, false);
> - if (ret)
> - goto err_disable_sysclk;
> -
> - return 0;
> -
> -err_disable_sysclk:
> - clk_disable_unprepare(master->sysclk);
> -
> -err_disable_pclk:
> - clk_disable_unprepare(master->pclk);
> -
> - return ret;
> + return i3c_master_register(&master->base, &pdev->dev,
> + &cdns_i3c_master_ops, false);
> }
>
> static void cdns_i3c_master_remove(struct platform_device *pdev)
> @@ -1668,9 +1644,6 @@ static void cdns_i3c_master_remove(struct platform_device *pdev)
>
> cancel_work_sync(&master->hj_work);
> i3c_master_unregister(&master->base);
> -
> - clk_disable_unprepare(master->sysclk);
> - clk_disable_unprepare(master->pclk);
> }
>
> static struct platform_driver cdns_i3c_master = {
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-07-14 14:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-13 15:24 Krzysztof Kozlowski
2025-07-14 14:15 ` Frank Li [this message]
2025-07-14 14:40 ` Krzysztof Kozlowski
2025-07-14 15:04 ` Frank Li
2025-07-30 23:40 ` Alexandre Belloni
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=aHUQ7Ge97/glY+s7@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pgaj@cadence.com \
/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®