Message ID | 20230817024509.3951629-4-lizetao1@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mtd: Use devm_clk_get_enabled() to simplify the drivers. | expand |
Hi Li, lizetao1@huawei.com wrote on Thu, 17 Aug 2023 10:45:01 +0800: A few nits for all your commit logs aside from a comment below: > After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for Since commit > prepared and enabled clocks"), it can replace the pair of functions, , 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. > devm_clk_get() and clk_prepare_enable() with a single helper function > devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared > (or enabled) during the whole lifetime of the driver, it is unnecessary to Moreover, it is no longer necessary to unprepare and disable the clock explicitly. > unprepare and disable clock explicitly when remove driver or in the error > handling path. > > Signed-off-by: Li Zetao <lizetao1@huawei.com> > --- > drivers/mtd/nand/raw/fsmc_nand.c | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c > index 7b4742420dfc..ab1b9a5c93e9 100644 > --- a/drivers/mtd/nand/raw/fsmc_nand.c > +++ b/drivers/mtd/nand/raw/fsmc_nand.c [...] > @@ -1157,7 +1153,6 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) > dma_release_channel(host->read_dma_chan); > disable_clk: This label no longer makes sense, please rename it to "disable_fsmc" or something like that. > fsmc_nand_disable(host); > - clk_disable_unprepare(host->clk); > > return ret; > } Thanks, Miquèl
diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c index 7b4742420dfc..ab1b9a5c93e9 100644 --- a/drivers/mtd/nand/raw/fsmc_nand.c +++ b/drivers/mtd/nand/raw/fsmc_nand.c @@ -1066,16 +1066,12 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) host->regs_va = base + FSMC_NOR_REG_SIZE + (host->bank * FSMC_NAND_BANK_SZ); - host->clk = devm_clk_get(&pdev->dev, NULL); + host->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(host->clk)) { dev_err(&pdev->dev, "failed to fetch block clock\n"); return PTR_ERR(host->clk); } - ret = clk_prepare_enable(host->clk); - if (ret) - return ret; - /* * This device ID is actually a common AMBA ID as used on the * AMBA PrimeCell bus. However it is not a PrimeCell. @@ -1157,7 +1153,6 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) dma_release_channel(host->read_dma_chan); disable_clk: fsmc_nand_disable(host); - clk_disable_unprepare(host->clk); return ret; } @@ -1182,7 +1177,6 @@ static void fsmc_nand_remove(struct platform_device *pdev) dma_release_channel(host->write_dma_chan); dma_release_channel(host->read_dma_chan); } - clk_disable_unprepare(host->clk); } }
After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao <lizetao1@huawei.com> --- drivers/mtd/nand/raw/fsmc_nand.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)