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

mtd: rawnand: stm32_fmc2: 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, so drop
the label "err_clk_disable".

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-9-lizetao1@huawei.com

authored by

Li Zetao and committed by
Miquel Raynal
7ec53e2b 2b34e8bd

+4 -13
+4 -13
drivers/mtd/nand/raw/stm32_fmc2_nand.c
··· 1951 1951 1952 1952 init_completion(&nfc->complete); 1953 1953 1954 - nfc->clk = devm_clk_get(nfc->cdev, NULL); 1955 - if (IS_ERR(nfc->clk)) 1954 + nfc->clk = devm_clk_get_enabled(nfc->cdev, NULL); 1955 + if (IS_ERR(nfc->clk)) { 1956 + dev_err(dev, "can not get and enable the clock\n"); 1956 1957 return PTR_ERR(nfc->clk); 1957 - 1958 - ret = clk_prepare_enable(nfc->clk); 1959 - if (ret) { 1960 - dev_err(dev, "can not enable the clock\n"); 1961 - return ret; 1962 1958 } 1963 1959 1964 1960 rstc = devm_reset_control_get(dev, NULL); 1965 1961 if (IS_ERR(rstc)) { 1966 1962 ret = PTR_ERR(rstc); 1967 1963 if (ret == -EPROBE_DEFER) 1968 - goto err_clk_disable; 1964 + return ret; 1969 1965 } else { 1970 1966 reset_control_assert(rstc); 1971 1967 reset_control_deassert(rstc); ··· 2014 2018 sg_free_table(&nfc->dma_data_sg); 2015 2019 sg_free_table(&nfc->dma_ecc_sg); 2016 2020 2017 - err_clk_disable: 2018 - clk_disable_unprepare(nfc->clk); 2019 - 2020 2021 return ret; 2021 2022 } 2022 2023 ··· 2037 2044 2038 2045 sg_free_table(&nfc->dma_data_sg); 2039 2046 sg_free_table(&nfc->dma_ecc_sg); 2040 - 2041 - clk_disable_unprepare(nfc->clk); 2042 2047 2043 2048 stm32_fmc2_nfc_wp_enable(nand); 2044 2049 }