* [PATCH] mtd: st_spi_fsm: Use the devm_clk_get_enabled() helper function
@ 2023-04-16 9:16 Christophe JAILLET
2023-05-22 15:59 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2023-04-16 9:16 UTC (permalink / raw
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-mtd
Use the devm_clk_get_enabled() helper function instead of hand-writing it.
It saves some line of codes.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/mtd/devices/st_spi_fsm.c | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index 54861d889c30..3dbb1aa80bfa 100644
--- a/drivers/mtd/devices/st_spi_fsm.c
+++ b/drivers/mtd/devices/st_spi_fsm.c
@@ -2046,34 +2046,26 @@ static int stfsm_probe(struct platform_device *pdev)
return PTR_ERR(fsm->base);
}
- fsm->clk = devm_clk_get(&pdev->dev, NULL);
+ fsm->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(fsm->clk)) {
dev_err(fsm->dev, "Couldn't find EMI clock.\n");
return PTR_ERR(fsm->clk);
}
- ret = clk_prepare_enable(fsm->clk);
- if (ret) {
- dev_err(fsm->dev, "Failed to enable EMI clock.\n");
- return ret;
- }
-
mutex_init(&fsm->lock);
ret = stfsm_init(fsm);
if (ret) {
dev_err(&pdev->dev, "Failed to initialise FSM Controller\n");
- goto err_clk_unprepare;
+ return ret;
}
stfsm_fetch_platform_configs(pdev);
/* Detect SPI FLASH device */
info = stfsm_jedec_probe(fsm);
- if (!info) {
- ret = -ENODEV;
- goto err_clk_unprepare;
- }
+ if (!info)
+ return -ENODEV;
fsm->info = info;
/* Use device size to determine address width */
@@ -2089,7 +2081,7 @@ static int stfsm_probe(struct platform_device *pdev)
else
ret = stfsm_prepare_rwe_seqs_default(fsm);
if (ret)
- goto err_clk_unprepare;
+ return ret;
fsm->mtd.name = info->name;
fsm->mtd.dev.parent = &pdev->dev;
@@ -2112,13 +2104,7 @@ static int stfsm_probe(struct platform_device *pdev)
(long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
- ret = mtd_device_register(&fsm->mtd, NULL, 0);
- if (ret) {
-err_clk_unprepare:
- clk_disable_unprepare(fsm->clk);
- }
-
- return ret;
+ return mtd_device_register(&fsm->mtd, NULL, 0);
}
static int stfsm_remove(struct platform_device *pdev)
@@ -2127,8 +2113,6 @@ static int stfsm_remove(struct platform_device *pdev)
WARN_ON(mtd_device_unregister(&fsm->mtd));
- clk_disable_unprepare(fsm->clk);
-
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: st_spi_fsm: Use the devm_clk_get_enabled() helper function
2023-04-16 9:16 [PATCH] mtd: st_spi_fsm: Use the devm_clk_get_enabled() helper function Christophe JAILLET
@ 2023-05-22 15:59 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2023-05-22 15:59 UTC (permalink / raw
To: Christophe JAILLET, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: linux-kernel, kernel-janitors, linux-mtd
On Sun, 2023-04-16 at 09:16:36 UTC, Christophe JAILLET wrote:
> Use the devm_clk_get_enabled() helper function instead of hand-writing it.
> It saves some line of codes.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-22 16:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-16 9:16 [PATCH] mtd: st_spi_fsm: Use the devm_clk_get_enabled() helper function Christophe JAILLET
2023-05-22 15:59 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).