Skip to content

Commit 69d50d0

Browse files
Li Zetaoambarus
authored andcommitted
mtd: spi-nor: nxp-spifi: Use helper function devm_clk_get_enabled()
Since commit 7ef9651 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enable (and possibly prepare) the clocks for the whole lifetime of the device. Moreover, it is no longer necessary to unprepare and disable the clock explicitly, so drop the label "dis_clks" and "dis_clk_reg". Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Li Zetao <lizetao1@huawei.com> Link: https://lore.kernel.org/r/20230818074642.308166-12-lizetao1@huawei.com Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent 9d0164c commit 69d50d0

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

drivers/mtd/spi-nor/controllers/nxp-spifi.c

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -395,30 +395,18 @@ static int nxp_spifi_probe(struct platform_device *pdev)
395395
if (IS_ERR(spifi->flash_base))
396396
return PTR_ERR(spifi->flash_base);
397397

398-
spifi->clk_spifi = devm_clk_get(&pdev->dev, "spifi");
398+
spifi->clk_spifi = devm_clk_get_enabled(&pdev->dev, "spifi");
399399
if (IS_ERR(spifi->clk_spifi)) {
400-
dev_err(&pdev->dev, "spifi clock not found\n");
400+
dev_err(&pdev->dev, "spifi clock not found or unable to enable\n");
401401
return PTR_ERR(spifi->clk_spifi);
402402
}
403403

404-
spifi->clk_reg = devm_clk_get(&pdev->dev, "reg");
404+
spifi->clk_reg = devm_clk_get_enabled(&pdev->dev, "reg");
405405
if (IS_ERR(spifi->clk_reg)) {
406-
dev_err(&pdev->dev, "reg clock not found\n");
406+
dev_err(&pdev->dev, "reg clock not found or unable to enable\n");
407407
return PTR_ERR(spifi->clk_reg);
408408
}
409409

410-
ret = clk_prepare_enable(spifi->clk_reg);
411-
if (ret) {
412-
dev_err(&pdev->dev, "unable to enable reg clock\n");
413-
return ret;
414-
}
415-
416-
ret = clk_prepare_enable(spifi->clk_spifi);
417-
if (ret) {
418-
dev_err(&pdev->dev, "unable to enable spifi clock\n");
419-
goto dis_clk_reg;
420-
}
421-
422410
spifi->dev = &pdev->dev;
423411
platform_set_drvdata(pdev, spifi);
424412

@@ -431,33 +419,24 @@ static int nxp_spifi_probe(struct platform_device *pdev)
431419
flash_np = of_get_next_available_child(pdev->dev.of_node, NULL);
432420
if (!flash_np) {
433421
dev_err(&pdev->dev, "no SPI flash device to configure\n");
434-
ret = -ENODEV;
435-
goto dis_clks;
422+
return -ENODEV;
436423
}
437424

438425
ret = nxp_spifi_setup_flash(spifi, flash_np);
439426
of_node_put(flash_np);
440427
if (ret) {
441428
dev_err(&pdev->dev, "unable to setup flash chip\n");
442-
goto dis_clks;
429+
return ret;
443430
}
444431

445432
return 0;
446-
447-
dis_clks:
448-
clk_disable_unprepare(spifi->clk_spifi);
449-
dis_clk_reg:
450-
clk_disable_unprepare(spifi->clk_reg);
451-
return ret;
452433
}
453434

454435
static int nxp_spifi_remove(struct platform_device *pdev)
455436
{
456437
struct nxp_spifi *spifi = platform_get_drvdata(pdev);
457438

458439
mtd_device_unregister(&spifi->nor.mtd);
459-
clk_disable_unprepare(spifi->clk_spifi);
460-
clk_disable_unprepare(spifi->clk_reg);
461440

462441
return 0;
463442
}

0 commit comments

Comments
 (0)