* [PATCH] spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe()
@ 2026-11-23 16:23 Markus Elfring
2026-11-23 17:27 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2026-11-23 16:23 UTC (permalink / raw)
To: imx, linux-spi, linux-arm-kernel, kernel, Fabio Estevam,
Frank Li, Johan Hovold, Mark Brown, Sascha Hauer
Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
Florian Fainelli, Michal Simek
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 23 Nov 2026 17:07:22 +0100
* Reuse existing functionality from devm_clk_get_enabled() instead of
keeping duplicate source code.
* Delete clk_disable_unprepare() calls on error handling paths.
* Omit the label “out_put_per”.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/spi/spi-imx.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index cadf0b93f440..a99edfbf2d61 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -2319,22 +2319,14 @@ static int spi_imx_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(&pdev->dev, ret, "can't get irq%d\n", irq);
- spi_imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+ spi_imx->clk_ipg = devm_clk_get_enabled(&pdev->dev, "ipg");
if (IS_ERR(spi_imx->clk_ipg))
return PTR_ERR(spi_imx->clk_ipg);
- spi_imx->clk_per = devm_clk_get(&pdev->dev, "per");
+ spi_imx->clk_per = devm_clk_get_enabled(&pdev->dev, "per");
if (IS_ERR(spi_imx->clk_per))
return PTR_ERR(spi_imx->clk_per);
- ret = clk_prepare_enable(spi_imx->clk_per);
- if (ret)
- return ret;
-
- ret = clk_prepare_enable(spi_imx->clk_ipg);
- if (ret)
- goto out_put_per;
-
pm_runtime_set_autosuspend_delay(spi_imx->dev, MXC_RPM_TIMEOUT);
pm_runtime_use_autosuspend(spi_imx->dev);
pm_runtime_get_noresume(spi_imx->dev);
@@ -2378,11 +2370,6 @@ static int spi_imx_probe(struct platform_device *pdev)
pm_runtime_disable(spi_imx->dev);
pm_runtime_put_noidle(spi_imx->dev);
pm_runtime_set_suspended(&pdev->dev);
-
- clk_disable_unprepare(spi_imx->clk_ipg);
-out_put_per:
- clk_disable_unprepare(spi_imx->clk_per);
-
return ret;
}
--
2.56.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe()
2026-11-23 16:23 [PATCH] spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe() Markus Elfring
@ 2026-11-23 17:27 ` Andy Shevchenko
2026-11-23 18:24 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-11-23 17:27 UTC (permalink / raw)
To: Markus Elfring
Cc: imx, linux-spi, linux-arm-kernel, kernel, Fabio Estevam,
Frank Li, Johan Hovold, Mark Brown, Sascha Hauer, LKML,
kernel-janitors, Christophe Jaillet, Florian Fainelli,
Michal Simek
On Mon, Nov 23, 2026 at 05:23:12PM +0100, Markus Elfring wrote:
>
> * Reuse existing functionality from devm_clk_get_enabled() instead of
> keeping duplicate source code.
>
> * Delete clk_disable_unprepare() calls on error handling paths.
>
> * Omit the label “out_put_per”.
>
> This issue was detected by using the Coccinelle software.
This now messes up with the PM callbacks at remove stage.
It's not trivial how to make it correct.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe()
2026-11-23 17:27 ` Andy Shevchenko
@ 2026-11-23 18:24 ` Markus Elfring
2026-11-23 18:49 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2026-11-23 18:24 UTC (permalink / raw)
To: Andy Shevchenko, imx, linux-spi, linux-arm-kernel, kernel
Cc: Fabio Estevam, Frank Li, Johan Hovold, Mark Brown, Sascha Hauer,
LKML, kernel-janitors, Christophe Jaillet, Florian Fainelli,
Michal Simek
>> * Reuse existing functionality from devm_clk_get_enabled() instead of
>> keeping duplicate source code.
>>
>> * Delete clk_disable_unprepare() calls on error handling paths.
>>
>> * Omit the label “out_put_per”.
>>
>> This issue was detected by using the Coccinelle software.
>
> This now messes up with the PM callbacks at remove stage.
> It's not trivial how to make it correct.
Is there a need to adjust and extend devres programming interfaces any more?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/driver-model/devres.rst?h=v7.4-rc4#n242
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe()
2026-11-23 18:24 ` Markus Elfring
@ 2026-11-23 18:49 ` Andy Shevchenko
2026-11-23 19:02 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-11-23 18:49 UTC (permalink / raw)
To: Markus Elfring
Cc: imx, linux-spi, linux-arm-kernel, kernel, Fabio Estevam,
Frank Li, Johan Hovold, Mark Brown, Sascha Hauer, LKML,
kernel-janitors, Christophe Jaillet, Florian Fainelli,
Michal Simek
On Mon, Nov 23, 2026 at 07:24:21PM +0100, Markus Elfring wrote:
> >> * Reuse existing functionality from devm_clk_get_enabled() instead of
> >> keeping duplicate source code.
> >>
> >> * Delete clk_disable_unprepare() calls on error handling paths.
> >>
> >> * Omit the label “out_put_per”.
> >>
> >> This issue was detected by using the Coccinelle software.
> >
> > This now messes up with the PM callbacks at remove stage.
> > It's not trivial how to make it correct.
> Is there a need to adjust and extend devres programming interfaces any more?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/driver-model/devres.rst?h=v7.4-rc4#n242
I guess you did get my point. You can't simply do what you have done in this
patch, because the devm*() will do something with clock reference counting on
remove stage _after_ the driver.
NAK to this change.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe()
2026-11-23 18:49 ` Andy Shevchenko
@ 2026-11-23 19:02 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-11-23 19:02 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Markus Elfring, imx, linux-spi, linux-arm-kernel, kernel,
Fabio Estevam, Frank Li, Johan Hovold, Sascha Hauer, LKML,
kernel-janitors, Christophe Jaillet, Florian Fainelli,
Michal Simek
[-- Attachment #1: Type: text/plain, Size: 1147 bytes --]
On Mon, Nov 23, 2026 at 08:49:50PM +0200, Andy Shevchenko wrote:
> On Mon, Nov 23, 2026 at 07:24:21PM +0100, Markus Elfring wrote:
> > >> * Reuse existing functionality from devm_clk_get_enabled() instead of
> > >> keeping duplicate source code.
> > >>
> > >> * Delete clk_disable_unprepare() calls on error handling paths.
> > >>
> > >> * Omit the label “out_put_per”.
> > >>
> > >> This issue was detected by using the Coccinelle software.
> > >
> > > This now messes up with the PM callbacks at remove stage.
> > > It's not trivial how to make it correct.
> > Is there a need to adjust and extend devres programming interfaces any more?
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/driver-model/devres.rst?h=v7.4-rc4#n242
>
> I guess you did get my point. You can't simply do what you have done in this
> patch, because the devm*() will do something with clock reference counting on
> remove stage _after_ the driver.
Feel free to ignore Markus, he has a long history of sending
unhelpful review comments and continues to ignore repeated requests
to stop.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-23 19:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 16:23 [PATCH] spi: imx: Use devm_clk_get_enabled() calls in spi_imx_probe() Markus Elfring
2026-11-23 17:27 ` Andy Shevchenko
2026-11-23 18:24 ` Markus Elfring
2026-11-23 18:49 ` Andy Shevchenko
2026-11-23 19:02 ` Mark Brown
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®