From: Frank Li <Frank.li@nxp.com>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
linux-pm@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] pmdomain: imx93-blk-ctrl: convert to devm_* only
Date: Mon, 1 Dec 2025 17:41:43 -0500 [thread overview]
Message-ID: <aS4ZpyhrJ1IpUCKv@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20251201-v6-18-topic-imx93-blkctrl-v1-2-b57a72e60105@pengutronix.de>
On Mon, Dec 01, 2025 at 06:12:06PM +0100, Marco Felsch wrote:
> Some APIs used by this driver don't have devm_ helpers yet. Instead of
> using the devm_add_action_or_reset() the current driver is based on hand
> crafted error goto paths and a .remove() callback.
>
> Convert the driver to devm_ APIs only by making use of
> devm_add_action_or_reset() and devm_pm_runtime_enable() to simplify the
> release and error path.
Nit: I think keep this paragaph should be enough.
>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> drivers/pmdomain/imx/imx93-blk-ctrl.c | 64 +++++++++++++++--------------------
> 1 file changed, 27 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/pmdomain/imx/imx93-blk-ctrl.c b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> index 2aa163aef8de4ee901b9cde76ce2aad246c8c08a..13b0de6dd689cf944e034f7666a4e97b0118e3bd 100644
> --- a/drivers/pmdomain/imx/imx93-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx93-blk-ctrl.c
> @@ -188,6 +188,20 @@ static int imx93_blk_ctrl_power_off(struct generic_pm_domain *genpd)
> return 0;
> }
>
...
> static struct lock_class_key blk_ctrl_genpd_lock_class;
>
> static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> @@ -256,10 +270,8 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> domain->clks[j].id = data->clk_names[j];
>
> ret = devm_clk_bulk_get(dev, data->num_clks, domain->clks);
> - if (ret) {
> - dev_err_probe(dev, ret, "failed to get clock\n");
> - goto cleanup_pds;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to get clock\n");
>
> domain->genpd.name = data->name;
> domain->genpd.power_on = imx93_blk_ctrl_power_on;
> @@ -267,11 +279,12 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> domain->bc = bc;
>
> ret = pm_genpd_init(&domain->genpd, NULL, true);
> - if (ret) {
> - dev_err_probe(dev, ret, "failed to init power domain\n");
> - goto cleanup_pds;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to init power domain\n");
>
> + ret = devm_add_action_or_reset(dev, imx93_release_pm_genpd, &domain->genpd);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to add pm_genpd release callback\n");
> /*
> * We use runtime PM to trigger power on/off of the upstream GPC
> * domain, as a strict hierarchical parent/child power domain
> @@ -288,39 +301,17 @@ static int imx93_blk_ctrl_probe(struct platform_device *pdev)
> bc->onecell_data.domains[i] = &domain->genpd;
> }
>
> - pm_runtime_enable(dev);
> + devm_pm_runtime_enable(dev);
Need check return value
>
> ret = of_genpd_add_provider_onecell(dev->of_node, &bc->onecell_data);
> - if (ret) {
> - dev_err_probe(dev, ret, "failed to add power domain provider\n");
> - goto cleanup_pds;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to add power domain provider\n");
>
> - dev_set_drvdata(dev, bc);
why remove dev_set_drvdata(dev, bc)
Frank
> + ret = devm_add_action_or_reset(dev, imx93_release_genpd_provider, dev->of_node);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to add genpd_provider release callback\n");
>
> return 0;
> -
> -cleanup_pds:
> - for (i--; i >= 0; i--)
> - pm_genpd_remove(&bc->domains[i].genpd);
> -
> - return ret;
> -}
> -
> -static void imx93_blk_ctrl_remove(struct platform_device *pdev)
> -{
> - struct imx93_blk_ctrl *bc = dev_get_drvdata(&pdev->dev);
> - int i;
> -
> - of_genpd_del_provider(pdev->dev.of_node);
> -
> - pm_runtime_disable(&pdev->dev);
> -
> - for (i = 0; i < bc->onecell_data.num_domains; i++) {
> - struct imx93_blk_ctrl_domain *domain = &bc->domains[i];
> -
> - pm_genpd_remove(&domain->genpd);
> - }
> }
>
> static const struct imx93_blk_ctrl_domain_data imx93_media_blk_ctl_domain_data[] = {
> @@ -455,7 +446,6 @@ MODULE_DEVICE_TABLE(of, imx93_blk_ctrl_of_match);
>
> static struct platform_driver imx93_blk_ctrl_driver = {
> .probe = imx93_blk_ctrl_probe,
> - .remove = imx93_blk_ctrl_remove,
> .driver = {
> .name = "imx93-blk-ctrl",
> .of_match_table = imx93_blk_ctrl_of_match,
>
> --
> 2.47.3
>
next prev parent reply other threads:[~2025-12-01 22:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 17:12 [PATCH 0/3] i.MX91/93 BLK-CTRL improvements Marco Felsch
2025-12-01 17:12 ` [PATCH 1/3] pmdomain: imx93-blk-ctrl: cleanup error path Marco Felsch
2025-12-01 22:37 ` Frank Li
2025-12-02 7:48 ` Alexander Stein
2025-12-01 17:12 ` [PATCH 2/3] pmdomain: imx93-blk-ctrl: convert to devm_* only Marco Felsch
2025-12-01 22:41 ` Frank Li [this message]
2025-12-02 7:57 ` Marco Felsch
2025-12-01 17:12 ` [PATCH 3/3] pmdomain: imx93-blk-ctrl: add support for optional subnodes Marco Felsch
2025-12-01 22:42 ` Frank Li
2025-12-02 7:49 ` Alexander Stein
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=aS4ZpyhrJ1IpUCKv@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=m.felsch@pengutronix.de \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=ulf.hansson@linaro.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