Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()

Since commit 7ef9651e9792 ("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 enables (and possibly
prepares) the clocks for the whole lifetime of the device. Moreover, it is
no longer necessary to unprepare and disable the clocks explicitly. The
label "disable_clk" no longer makes sense, rename it to "disable_fsmc".

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230821031737.1973183-4-lizetao1@huawei.com

authored by

Li Zetao and committed by
Miquel Raynal
ee0152d0 a36201ac

+3 -9
+3 -9
drivers/mtd/nand/raw/fsmc_nand.c
··· 1066 1066 host->regs_va = base + FSMC_NOR_REG_SIZE + 1067 1067 (host->bank * FSMC_NAND_BANK_SZ); 1068 1068 1069 - host->clk = devm_clk_get(&pdev->dev, NULL); 1069 + host->clk = devm_clk_get_enabled(&pdev->dev, NULL); 1070 1070 if (IS_ERR(host->clk)) { 1071 1071 dev_err(&pdev->dev, "failed to fetch block clock\n"); 1072 1072 return PTR_ERR(host->clk); 1073 1073 } 1074 - 1075 - ret = clk_prepare_enable(host->clk); 1076 - if (ret) 1077 - return ret; 1078 1074 1079 1075 /* 1080 1076 * This device ID is actually a common AMBA ID as used on the ··· 1107 1111 if (!host->read_dma_chan) { 1108 1112 dev_err(&pdev->dev, "Unable to get read dma channel\n"); 1109 1113 ret = -ENODEV; 1110 - goto disable_clk; 1114 + goto disable_fsmc; 1111 1115 } 1112 1116 host->write_dma_chan = dma_request_channel(mask, filter, NULL); 1113 1117 if (!host->write_dma_chan) { ··· 1151 1155 release_dma_read_chan: 1152 1156 if (host->mode == USE_DMA_ACCESS) 1153 1157 dma_release_channel(host->read_dma_chan); 1154 - disable_clk: 1158 + disable_fsmc: 1155 1159 fsmc_nand_disable(host); 1156 - clk_disable_unprepare(host->clk); 1157 1160 1158 1161 return ret; 1159 1162 } ··· 1177 1182 dma_release_channel(host->write_dma_chan); 1178 1183 dma_release_channel(host->read_dma_chan); 1179 1184 } 1180 - clk_disable_unprepare(host->clk); 1181 1185 } 1182 1186 } 1183 1187