Skip to content

Commit a95da27

Browse files
Li Zetaomiquelraynal
authored andcommitted
mtd: rawnand: sunxi: 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 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, so drop the label "out_mod_clk_unprepare" and "out_ahb_clk_unprepare". 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-10-lizetao1@huawei.com
1 parent 7ec53e2 commit a95da27

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

drivers/mtd/nand/raw/sunxi_nand.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,37 +2095,26 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
20952095
if (irq < 0)
20962096
return irq;
20972097

2098-
nfc->ahb_clk = devm_clk_get(dev, "ahb");
2098+
nfc->ahb_clk = devm_clk_get_enabled(dev, "ahb");
20992099
if (IS_ERR(nfc->ahb_clk)) {
21002100
dev_err(dev, "failed to retrieve ahb clk\n");
21012101
return PTR_ERR(nfc->ahb_clk);
21022102
}
21032103

2104-
ret = clk_prepare_enable(nfc->ahb_clk);
2105-
if (ret)
2106-
return ret;
2107-
2108-
nfc->mod_clk = devm_clk_get(dev, "mod");
2104+
nfc->mod_clk = devm_clk_get_enabled(dev, "mod");
21092105
if (IS_ERR(nfc->mod_clk)) {
21102106
dev_err(dev, "failed to retrieve mod clk\n");
2111-
ret = PTR_ERR(nfc->mod_clk);
2112-
goto out_ahb_clk_unprepare;
2107+
return PTR_ERR(nfc->mod_clk);
21132108
}
21142109

2115-
ret = clk_prepare_enable(nfc->mod_clk);
2116-
if (ret)
2117-
goto out_ahb_clk_unprepare;
2118-
21192110
nfc->reset = devm_reset_control_get_optional_exclusive(dev, "ahb");
2120-
if (IS_ERR(nfc->reset)) {
2121-
ret = PTR_ERR(nfc->reset);
2122-
goto out_mod_clk_unprepare;
2123-
}
2111+
if (IS_ERR(nfc->reset))
2112+
return PTR_ERR(nfc->reset);
21242113

21252114
ret = reset_control_deassert(nfc->reset);
21262115
if (ret) {
21272116
dev_err(dev, "reset err %d\n", ret);
2128-
goto out_mod_clk_unprepare;
2117+
return ret;
21292118
}
21302119

21312120
nfc->caps = of_device_get_match_data(&pdev->dev);
@@ -2164,10 +2153,6 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
21642153
dma_release_channel(nfc->dmac);
21652154
out_ahb_reset_reassert:
21662155
reset_control_assert(nfc->reset);
2167-
out_mod_clk_unprepare:
2168-
clk_disable_unprepare(nfc->mod_clk);
2169-
out_ahb_clk_unprepare:
2170-
clk_disable_unprepare(nfc->ahb_clk);
21712156

21722157
return ret;
21732158
}
@@ -2182,8 +2167,6 @@ static void sunxi_nfc_remove(struct platform_device *pdev)
21822167

21832168
if (nfc->dmac)
21842169
dma_release_channel(nfc->dmac);
2185-
clk_disable_unprepare(nfc->mod_clk);
2186-
clk_disable_unprepare(nfc->ahb_clk);
21872170
}
21882171

21892172
static const struct sunxi_nfc_caps sunxi_nfc_a10_caps = {

0 commit comments

Comments
 (0)