linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers.
@ 2023-08-17  2:44 Li Zetao
  2023-08-17  2:44 ` [PATCH -next 01/11] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
                   ` (11 more replies)
  0 siblings, 12 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:44 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

Commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
and enabled clocks") provides a new helper function for prepared and
enabled clocks when a driver keeps a clock prepared (or enabled) during
the whole lifetime of the driver. So where drivers get clocks and enable
them immediately, it can be combined into a single function
devm_clk_get_*enabled(). Moreover, the unprepare and disable function
has been registered to devm_clk_state, and before devm_clk_state is
released, the clocks will be unprepareed and disable, so it is unnecessary
to unprepare and disable clock explicitly when remove drivers or in the
error handling path.

Li Zetao (11):
  mtd: spear_smi: Use helper function devm_clk_get_enabled()
  mtd: rawnand: arasan: Use helper function devm_clk_get_enabled()
  mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()
  mtd: rawnand: intel: Use helper function devm_clk_get_enabled()
  mtd: rawnand: lpc32xx_slc: Use helper function devm_clk_get_enabled()
  mtd: rawnand: mpc5121: Use helper function devm_clk_get_enabled()
  mtd: rawnand: mtk: Use helper function devm_clk_get_enabled()
  mtd: rawnand: stm32_fmc2: Use helper function devm_clk_get_enabled()
  mtd: rawnand: sunxi: Use helper function devm_clk_get_enabled()
  mtd: rawnand: vf610_nfc: Use helper function devm_clk_get_enabled()
  mtd: spi-nor: Use helper function devm_clk_get_enabled()

 drivers/mtd/devices/spear_smi.c               | 15 ++-------
 drivers/mtd/nand/raw/arasan-nand-controller.c | 29 +++-------------
 drivers/mtd/nand/raw/fsmc_nand.c              |  8 +----
 drivers/mtd/nand/raw/intel-nand-controller.c  | 15 ++-------
 drivers/mtd/nand/raw/lpc32xx_slc.c            | 12 ++-----
 drivers/mtd/nand/raw/mpc5121_nfc.c            | 11 ++-----
 drivers/mtd/nand/raw/mtk_nand.c               | 20 ++++-------
 drivers/mtd/nand/raw/stm32_fmc2_nand.c        | 17 +++-------
 drivers/mtd/nand/raw/sunxi_nand.c             | 29 ++++------------
 drivers/mtd/nand/raw/vf610_nfc.c              | 29 +++++-----------
 drivers/mtd/spi-nor/controllers/nxp-spifi.c   | 33 ++++---------------
 11 files changed, 48 insertions(+), 170 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH -next 01/11] mtd: spear_smi: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
@ 2023-08-17  2:44 ` Li Zetao
  2023-08-17  2:45 ` [PATCH -next 02/11] mtd: rawnand: arasan: " Li Zetao
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:44 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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/devices/spear_smi.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index 93bca5225116..0a35e5236ae5 100644
--- a/drivers/mtd/devices/spear_smi.c
+++ b/drivers/mtd/devices/spear_smi.c
@@ -993,21 +993,17 @@ static int spear_smi_probe(struct platform_device *pdev)
 		dev->num_flashes = MAX_NUM_FLASH_CHIP;
 	}
 
-	dev->clk = devm_clk_get(&pdev->dev, NULL);
+	dev->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(dev->clk)) {
 		ret = PTR_ERR(dev->clk);
 		goto err;
 	}
 
-	ret = clk_prepare_enable(dev->clk);
-	if (ret)
-		goto err;
-
 	ret = devm_request_irq(&pdev->dev, irq, spear_smi_int_handler, 0,
 			       pdev->name, dev);
 	if (ret) {
 		dev_err(&dev->pdev->dev, "SMI IRQ allocation failed\n");
-		goto err_irq;
+		goto err;
 	}
 
 	mutex_init(&dev->lock);
@@ -1020,14 +1016,11 @@ static int spear_smi_probe(struct platform_device *pdev)
 		ret = spear_smi_setup_banks(pdev, i, pdata->np[i]);
 		if (ret) {
 			dev_err(&dev->pdev->dev, "bank setup failed\n");
-			goto err_irq;
+			goto err;
 		}
 	}
 
 	return 0;
-
-err_irq:
-	clk_disable_unprepare(dev->clk);
 err:
 	return ret;
 }
@@ -1056,8 +1049,6 @@ static int spear_smi_remove(struct platform_device *pdev)
 		WARN_ON(mtd_device_unregister(&flash->mtd));
 	}
 
-	clk_disable_unprepare(dev->clk);
-
 	return 0;
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 02/11] mtd: rawnand: arasan: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
  2023-08-17  2:44 ` [PATCH -next 01/11] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  2:45 ` [PATCH -next 03/11] mtd: rawnand: fsmc: " Li Zetao
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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/arasan-nand-controller.c | 29 ++++---------------
 1 file changed, 5 insertions(+), 24 deletions(-)

diff --git a/drivers/mtd/nand/raw/arasan-nand-controller.c b/drivers/mtd/nand/raw/arasan-nand-controller.c
index 906eef70cb6d..4621ec549cc7 100644
--- a/drivers/mtd/nand/raw/arasan-nand-controller.c
+++ b/drivers/mtd/nand/raw/arasan-nand-controller.c
@@ -1440,45 +1440,29 @@ static int anfc_probe(struct platform_device *pdev)
 
 	anfc_reset(nfc);
 
-	nfc->controller_clk = devm_clk_get(&pdev->dev, "controller");
+	nfc->controller_clk = devm_clk_get_enabled(&pdev->dev, "controller");
 	if (IS_ERR(nfc->controller_clk))
 		return PTR_ERR(nfc->controller_clk);
 
-	nfc->bus_clk = devm_clk_get(&pdev->dev, "bus");
+	nfc->bus_clk = devm_clk_get_enabled(&pdev->dev, "bus");
 	if (IS_ERR(nfc->bus_clk))
 		return PTR_ERR(nfc->bus_clk);
 
-	ret = clk_prepare_enable(nfc->controller_clk);
-	if (ret)
-		return ret;
-
-	ret = clk_prepare_enable(nfc->bus_clk);
-	if (ret)
-		goto disable_controller_clk;
-
 	ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
 	if (ret)
-		goto disable_bus_clk;
+		return ret;
 
 	ret = anfc_parse_cs(nfc);
 	if (ret)
-		goto disable_bus_clk;
+		return ret;
 
 	ret = anfc_chips_init(nfc);
 	if (ret)
-		goto disable_bus_clk;
+		return ret;
 
 	platform_set_drvdata(pdev, nfc);
 
 	return 0;
-
-disable_bus_clk:
-	clk_disable_unprepare(nfc->bus_clk);
-
-disable_controller_clk:
-	clk_disable_unprepare(nfc->controller_clk);
-
-	return ret;
 }
 
 static void anfc_remove(struct platform_device *pdev)
@@ -1486,9 +1470,6 @@ static void anfc_remove(struct platform_device *pdev)
 	struct arasan_nfc *nfc = platform_get_drvdata(pdev);
 
 	anfc_chips_cleanup(nfc);
-
-	clk_disable_unprepare(nfc->bus_clk);
-	clk_disable_unprepare(nfc->controller_clk);
 }
 
 static const struct of_device_id anfc_ids[] = {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 03/11] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
  2023-08-17  2:44 ` [PATCH -next 01/11] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
  2023-08-17  2:45 ` [PATCH -next 02/11] mtd: rawnand: arasan: " Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  8:31   ` Miquel Raynal
  2023-08-17  2:45 ` [PATCH -next 04/11] mtd: rawnand: intel: " Li Zetao
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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(-)

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);
 	}
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 04/11] mtd: rawnand: intel: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
                   ` (2 preceding siblings ...)
  2023-08-17  2:45 ` [PATCH -next 03/11] mtd: rawnand: fsmc: " Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  2:45 ` [PATCH -next 05/11] mtd: rawnand: lpc32xx_slc: " Li Zetao
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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/intel-nand-controller.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/nand/raw/intel-nand-controller.c b/drivers/mtd/nand/raw/intel-nand-controller.c
index a9909eb08124..cb5d88f42297 100644
--- a/drivers/mtd/nand/raw/intel-nand-controller.c
+++ b/drivers/mtd/nand/raw/intel-nand-controller.c
@@ -626,16 +626,10 @@ static int ebu_nand_probe(struct platform_device *pdev)
 		goto err_of_node_put;
 	}
 
-	ebu_host->clk = devm_clk_get(dev, NULL);
+	ebu_host->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(ebu_host->clk)) {
 		ret = dev_err_probe(dev, PTR_ERR(ebu_host->clk),
-				    "failed to get clock\n");
-		goto err_of_node_put;
-	}
-
-	ret = clk_prepare_enable(ebu_host->clk);
-	if (ret) {
-		dev_err(dev, "failed to enable clock: %d\n", ret);
+				    "failed to get and enable clock\n");
 		goto err_of_node_put;
 	}
 
@@ -643,7 +637,7 @@ static int ebu_nand_probe(struct platform_device *pdev)
 	if (IS_ERR(ebu_host->dma_tx)) {
 		ret = dev_err_probe(dev, PTR_ERR(ebu_host->dma_tx),
 				    "failed to request DMA tx chan!.\n");
-		goto err_disable_unprepare_clk;
+		goto err_of_node_put;
 	}
 
 	ebu_host->dma_rx = dma_request_chan(dev, "rx");
@@ -698,8 +692,6 @@ static int ebu_nand_probe(struct platform_device *pdev)
 	nand_cleanup(&ebu_host->chip);
 err_cleanup_dma:
 	ebu_dma_cleanup(ebu_host);
-err_disable_unprepare_clk:
-	clk_disable_unprepare(ebu_host->clk);
 err_of_node_put:
 	of_node_put(chip_np);
 
@@ -716,7 +708,6 @@ static void ebu_nand_remove(struct platform_device *pdev)
 	nand_cleanup(&ebu_host->chip);
 	ebu_nand_disable(&ebu_host->chip);
 	ebu_dma_cleanup(ebu_host);
-	clk_disable_unprepare(ebu_host->clk);
 }
 
 static const struct of_device_id ebu_nand_match[] = {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 05/11] mtd: rawnand: lpc32xx_slc: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
                   ` (3 preceding siblings ...)
  2023-08-17  2:45 ` [PATCH -next 04/11] mtd: rawnand: intel: " Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  2:45 ` [PATCH -next 06/11] mtd: rawnand: mpc5121: " Li Zetao
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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/lpc32xx_slc.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c
index 2201264d3c37..1c5fa855b9f2 100644
--- a/drivers/mtd/nand/raw/lpc32xx_slc.c
+++ b/drivers/mtd/nand/raw/lpc32xx_slc.c
@@ -871,15 +871,12 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 	mtd->dev.parent = &pdev->dev;
 
 	/* Get NAND clock */
-	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, "Clock failure\n");
 		res = -ENOENT;
 		goto enable_wp;
 	}
-	res = clk_prepare_enable(host->clk);
-	if (res)
-		goto enable_wp;
 
 	/* Set NAND IO addresses and command/ready functions */
 	chip->legacy.IO_ADDR_R = SLC_DATA(host->io_base);
@@ -907,13 +904,13 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 				      GFP_KERNEL);
 	if (host->data_buf == NULL) {
 		res = -ENOMEM;
-		goto unprepare_clk;
+		goto enable_wp;
 	}
 
 	res = lpc32xx_nand_dma_setup(host);
 	if (res) {
 		res = -EIO;
-		goto unprepare_clk;
+		goto enable_wp;
 	}
 
 	/* Find NAND device */
@@ -934,8 +931,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 	nand_cleanup(chip);
 release_dma:
 	dma_release_channel(host->dma_chan);
-unprepare_clk:
-	clk_disable_unprepare(host->clk);
 enable_wp:
 	lpc32xx_wp_enable(host);
 
@@ -962,7 +957,6 @@ static void lpc32xx_nand_remove(struct platform_device *pdev)
 	tmp &= ~SLCCFG_CE_LOW;
 	writel(tmp, SLC_CTRL(host->io_base));
 
-	clk_disable_unprepare(host->clk);
 	lpc32xx_wp_enable(host);
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 06/11] mtd: rawnand: mpc5121: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
                   ` (4 preceding siblings ...)
  2023-08-17  2:45 ` [PATCH -next 05/11] mtd: rawnand: lpc32xx_slc: " Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  2:45 ` [PATCH -next 07/11] mtd: rawnand: mtk: " Li Zetao
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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/mpc5121_nfc.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/mpc5121_nfc.c b/drivers/mtd/nand/raw/mpc5121_nfc.c
index 6e8e790f84e7..215610f808f1 100644
--- a/drivers/mtd/nand/raw/mpc5121_nfc.c
+++ b/drivers/mtd/nand/raw/mpc5121_nfc.c
@@ -595,8 +595,6 @@ static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd)
 	struct nand_chip *chip = mtd_to_nand(mtd);
 	struct mpc5121_nfc_prv *prv = nand_get_controller_data(chip);
 
-	clk_disable_unprepare(prv->clk);
-
 	if (prv->csreg)
 		iounmap(prv->csreg);
 }
@@ -717,17 +715,12 @@ static int mpc5121_nfc_probe(struct platform_device *op)
 	}
 
 	/* Enable NFC clock */
-	clk = devm_clk_get(dev, "ipg");
+	clk = devm_clk_get_enabled(dev, "ipg");
 	if (IS_ERR(clk)) {
-		dev_err(dev, "Unable to acquire NFC clock!\n");
+		dev_err(dev, "Unable to acquire and enable NFC clock!\n");
 		retval = PTR_ERR(clk);
 		goto error;
 	}
-	retval = clk_prepare_enable(clk);
-	if (retval) {
-		dev_err(dev, "Unable to enable NFC clock!\n");
-		goto error;
-	}
 	prv->clk = clk;
 
 	/* Reset NAND Flash controller */
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 07/11] mtd: rawnand: mtk: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
                   ` (5 preceding siblings ...)
  2023-08-17  2:45 ` [PATCH -next 06/11] mtd: rawnand: mpc5121: " Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  8:34   ` Miquel Raynal
  2023-08-17  2:45 ` [PATCH -next 08/11] mtd: rawnand: stm32_fmc2: " Li Zetao
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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. The mtk_nfc_enable_clk() is a helper function that enables
the "clk->nfi_clk" and "clk->pad_clk", it can be combined into
devm_clk_get_enabled().

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/mtd/nand/raw/mtk_nand.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c
index b6eb8cb6b5e9..0d185e650aaf 100644
--- a/drivers/mtd/nand/raw/mtk_nand.c
+++ b/drivers/mtd/nand/raw/mtk_nand.c
@@ -1545,40 +1545,36 @@ static int mtk_nfc_probe(struct platform_device *pdev)
 		goto release_ecc;
 	}
 
-	nfc->clk.nfi_clk = devm_clk_get(dev, "nfi_clk");
+	nfc->clk.nfi_clk = devm_clk_get_enabled(dev, "nfi_clk");
 	if (IS_ERR(nfc->clk.nfi_clk)) {
 		dev_err(dev, "no clk\n");
 		ret = PTR_ERR(nfc->clk.nfi_clk);
 		goto release_ecc;
 	}
 
-	nfc->clk.pad_clk = devm_clk_get(dev, "pad_clk");
+	nfc->clk.pad_clk = devm_clk_get_enabled(dev, "pad_clk");
 	if (IS_ERR(nfc->clk.pad_clk)) {
 		dev_err(dev, "no pad clk\n");
 		ret = PTR_ERR(nfc->clk.pad_clk);
 		goto release_ecc;
 	}
 
-	ret = mtk_nfc_enable_clk(dev, &nfc->clk);
-	if (ret)
-		goto release_ecc;
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		ret = -EINVAL;
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	ret = devm_request_irq(dev, irq, mtk_nfc_irq, 0x0, "mtk-nand", nfc);
 	if (ret) {
 		dev_err(dev, "failed to request nfi irq\n");
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	ret = dma_set_mask(dev, DMA_BIT_MASK(32));
 	if (ret) {
 		dev_err(dev, "failed to set dma mask\n");
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	platform_set_drvdata(pdev, nfc);
@@ -1586,14 +1582,11 @@ static int mtk_nfc_probe(struct platform_device *pdev)
 	ret = mtk_nfc_nand_chips_init(dev, nfc);
 	if (ret) {
 		dev_err(dev, "failed to init nand chips\n");
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	return 0;
 
-clk_disable:
-	mtk_nfc_disable_clk(&nfc->clk);
-
 release_ecc:
 	mtk_ecc_release(nfc->ecc);
 
@@ -1618,7 +1611,6 @@ static void mtk_nfc_remove(struct platform_device *pdev)
 	}
 
 	mtk_ecc_release(nfc->ecc);
-	mtk_nfc_disable_clk(&nfc->clk);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 08/11] mtd: rawnand: stm32_fmc2: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
                   ` (6 preceding siblings ...)
  2023-08-17  2:45 ` [PATCH -next 07/11] mtd: rawnand: mtk: " Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  2:45 ` [PATCH -next 09/11] mtd: rawnand: sunxi: " Li Zetao
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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/stm32_fmc2_nand.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
index 2f9e43f64dd7..88811139aaf5 100644
--- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
+++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
@@ -1951,21 +1951,17 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
 
 	init_completion(&nfc->complete);
 
-	nfc->clk = devm_clk_get(nfc->cdev, NULL);
-	if (IS_ERR(nfc->clk))
+	nfc->clk = devm_clk_get_enabled(nfc->cdev, NULL);
+	if (IS_ERR(nfc->clk)) {
+		dev_err(dev, "can not get and enable the clock\n");
 		return PTR_ERR(nfc->clk);
-
-	ret = clk_prepare_enable(nfc->clk);
-	if (ret) {
-		dev_err(dev, "can not enable the clock\n");
-		return ret;
 	}
 
 	rstc = devm_reset_control_get(dev, NULL);
 	if (IS_ERR(rstc)) {
 		ret = PTR_ERR(rstc);
 		if (ret == -EPROBE_DEFER)
-			goto err_clk_disable;
+			return ret;
 	} else {
 		reset_control_assert(rstc);
 		reset_control_deassert(rstc);
@@ -2018,9 +2014,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
 	sg_free_table(&nfc->dma_data_sg);
 	sg_free_table(&nfc->dma_ecc_sg);
 
-err_clk_disable:
-	clk_disable_unprepare(nfc->clk);
-
 	return ret;
 }
 
@@ -2045,8 +2038,6 @@ static void stm32_fmc2_nfc_remove(struct platform_device *pdev)
 	sg_free_table(&nfc->dma_data_sg);
 	sg_free_table(&nfc->dma_ecc_sg);
 
-	clk_disable_unprepare(nfc->clk);
-
 	stm32_fmc2_nfc_wp_enable(nand);
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 09/11] mtd: rawnand: sunxi: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
                   ` (7 preceding siblings ...)
  2023-08-17  2:45 ` [PATCH -next 08/11] mtd: rawnand: stm32_fmc2: " Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  2:45 ` [PATCH -next 10/11] mtd: rawnand: vf610_nfc: " Li Zetao
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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/sunxi_nand.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 64c09eae951d..9abf38049d35 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -2094,37 +2094,26 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	nfc->ahb_clk = devm_clk_get(dev, "ahb");
+	nfc->ahb_clk = devm_clk_get_enabled(dev, "ahb");
 	if (IS_ERR(nfc->ahb_clk)) {
 		dev_err(dev, "failed to retrieve ahb clk\n");
 		return PTR_ERR(nfc->ahb_clk);
 	}
 
-	ret = clk_prepare_enable(nfc->ahb_clk);
-	if (ret)
-		return ret;
-
-	nfc->mod_clk = devm_clk_get(dev, "mod");
+	nfc->mod_clk = devm_clk_get_enabled(dev, "mod");
 	if (IS_ERR(nfc->mod_clk)) {
 		dev_err(dev, "failed to retrieve mod clk\n");
-		ret = PTR_ERR(nfc->mod_clk);
-		goto out_ahb_clk_unprepare;
+		return PTR_ERR(nfc->mod_clk);
 	}
 
-	ret = clk_prepare_enable(nfc->mod_clk);
-	if (ret)
-		goto out_ahb_clk_unprepare;
-
 	nfc->reset = devm_reset_control_get_optional_exclusive(dev, "ahb");
-	if (IS_ERR(nfc->reset)) {
-		ret = PTR_ERR(nfc->reset);
-		goto out_mod_clk_unprepare;
-	}
+	if (IS_ERR(nfc->reset))
+		return PTR_ERR(nfc->reset);
 
 	ret = reset_control_deassert(nfc->reset);
 	if (ret) {
 		dev_err(dev, "reset err %d\n", ret);
-		goto out_mod_clk_unprepare;
+		return ret;
 	}
 
 	nfc->caps = of_device_get_match_data(&pdev->dev);
@@ -2163,10 +2152,6 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
 		dma_release_channel(nfc->dmac);
 out_ahb_reset_reassert:
 	reset_control_assert(nfc->reset);
-out_mod_clk_unprepare:
-	clk_disable_unprepare(nfc->mod_clk);
-out_ahb_clk_unprepare:
-	clk_disable_unprepare(nfc->ahb_clk);
 
 	return ret;
 }
@@ -2181,8 +2166,6 @@ static void sunxi_nfc_remove(struct platform_device *pdev)
 
 	if (nfc->dmac)
 		dma_release_channel(nfc->dmac);
-	clk_disable_unprepare(nfc->mod_clk);
-	clk_disable_unprepare(nfc->ahb_clk);
 }
 
 static const struct sunxi_nfc_caps sunxi_nfc_a10_caps = {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 10/11] mtd: rawnand: vf610_nfc: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
                   ` (8 preceding siblings ...)
  2023-08-17  2:45 ` [PATCH -next 09/11] mtd: rawnand: sunxi: " Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  2:45 ` [PATCH -next 11/11] mtd: spi-nor: " Li Zetao
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  11 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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/vf610_nfc.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
index dcdf33dbaef2..1ce9d5c2b1f7 100644
--- a/drivers/mtd/nand/raw/vf610_nfc.c
+++ b/drivers/mtd/nand/raw/vf610_nfc.c
@@ -834,21 +834,15 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 	if (IS_ERR(nfc->regs))
 		return PTR_ERR(nfc->regs);
 
-	nfc->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(nfc->clk))
+	nfc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
+	if (IS_ERR(nfc->clk)) {
+		dev_err(nfc->dev, "Unable to get and enable clock!\n");
 		return PTR_ERR(nfc->clk);
-
-	err = clk_prepare_enable(nfc->clk);
-	if (err) {
-		dev_err(nfc->dev, "Unable to enable clock!\n");
-		return err;
 	}
 
 	of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev);
-	if (!of_id) {
-		err = -ENODEV;
-		goto err_disable_clk;
-	}
+	if (!of_id)
+		return -ENODEV;
 
 	nfc->variant = (enum vf610_nfc_variant)of_id->data;
 
@@ -858,9 +852,8 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 			if (nand_get_flash_node(chip)) {
 				dev_err(nfc->dev,
 					"Only one NAND chip supported!\n");
-				err = -EINVAL;
 				of_node_put(child);
-				goto err_disable_clk;
+				return -EINVAL;
 			}
 
 			nand_set_flash_node(chip, child);
@@ -869,8 +862,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 
 	if (!nand_get_flash_node(chip)) {
 		dev_err(nfc->dev, "NAND chip sub-node missing!\n");
-		err = -ENODEV;
-		goto err_disable_clk;
+		return -ENODEV;
 	}
 
 	chip->options |= NAND_NO_SUBPAGE_WRITE;
@@ -880,7 +872,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 	err = devm_request_irq(nfc->dev, irq, vf610_nfc_irq, 0, DRV_NAME, nfc);
 	if (err) {
 		dev_err(nfc->dev, "Error requesting IRQ!\n");
-		goto err_disable_clk;
+		return err;
 	}
 
 	vf610_nfc_preinit_controller(nfc);
@@ -892,7 +884,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 	/* Scan the NAND chip */
 	err = nand_scan(chip, 1);
 	if (err)
-		goto err_disable_clk;
+		return err;
 
 	platform_set_drvdata(pdev, nfc);
 
@@ -904,8 +896,6 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 
 err_cleanup_nand:
 	nand_cleanup(chip);
-err_disable_clk:
-	clk_disable_unprepare(nfc->clk);
 	return err;
 }
 
@@ -918,7 +908,6 @@ static void vf610_nfc_remove(struct platform_device *pdev)
 	ret = mtd_device_unregister(nand_to_mtd(chip));
 	WARN_ON(ret);
 	nand_cleanup(chip);
-	clk_disable_unprepare(nfc->clk);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next 11/11] mtd: spi-nor: Use helper function devm_clk_get_enabled()
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
                   ` (9 preceding siblings ...)
  2023-08-17  2:45 ` [PATCH -next 10/11] mtd: rawnand: vf610_nfc: " Li Zetao
@ 2023-08-17  2:45 ` Li Zetao
  2023-08-17  8:37   ` Miquel Raynal
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li
  Cc: robh, martin.blumenstingl, philmd, geert+renesas,
	u.kleine-koenig, rogerq, paul, nicolas.ferre, yangyingliang,
	dmitry.torokhov, heiko, christophe.leroy, christophe.kerello,
	jinpu.wang, lizetao1, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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/spi-nor/controllers/nxp-spifi.c | 33 ++++-----------------
 1 file changed, 6 insertions(+), 27 deletions(-)

diff --git a/drivers/mtd/spi-nor/controllers/nxp-spifi.c b/drivers/mtd/spi-nor/controllers/nxp-spifi.c
index 337e83bf3362..5d8f47ab146f 100644
--- a/drivers/mtd/spi-nor/controllers/nxp-spifi.c
+++ b/drivers/mtd/spi-nor/controllers/nxp-spifi.c
@@ -394,30 +394,18 @@ static int nxp_spifi_probe(struct platform_device *pdev)
 	if (IS_ERR(spifi->flash_base))
 		return PTR_ERR(spifi->flash_base);
 
-	spifi->clk_spifi = devm_clk_get(&pdev->dev, "spifi");
+	spifi->clk_spifi = devm_clk_get_enabled(&pdev->dev, "spifi");
 	if (IS_ERR(spifi->clk_spifi)) {
-		dev_err(&pdev->dev, "spifi clock not found\n");
+		dev_err(&pdev->dev, "spifi clock not found or unable to enable\n");
 		return PTR_ERR(spifi->clk_spifi);
 	}
 
-	spifi->clk_reg = devm_clk_get(&pdev->dev, "reg");
+	spifi->clk_reg = devm_clk_get_enabled(&pdev->dev, "reg");
 	if (IS_ERR(spifi->clk_reg)) {
-		dev_err(&pdev->dev, "reg clock not found\n");
+		dev_err(&pdev->dev, "reg clock not found or unable to enable\n");
 		return PTR_ERR(spifi->clk_reg);
 	}
 
-	ret = clk_prepare_enable(spifi->clk_reg);
-	if (ret) {
-		dev_err(&pdev->dev, "unable to enable reg clock\n");
-		return ret;
-	}
-
-	ret = clk_prepare_enable(spifi->clk_spifi);
-	if (ret) {
-		dev_err(&pdev->dev, "unable to enable spifi clock\n");
-		goto dis_clk_reg;
-	}
-
 	spifi->dev = &pdev->dev;
 	platform_set_drvdata(pdev, spifi);
 
@@ -430,24 +418,17 @@ static int nxp_spifi_probe(struct platform_device *pdev)
 	flash_np = of_get_next_available_child(pdev->dev.of_node, NULL);
 	if (!flash_np) {
 		dev_err(&pdev->dev, "no SPI flash device to configure\n");
-		ret = -ENODEV;
-		goto dis_clks;
+		return -ENODEV;
 	}
 
 	ret = nxp_spifi_setup_flash(spifi, flash_np);
 	of_node_put(flash_np);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to setup flash chip\n");
-		goto dis_clks;
+		return ret;
 	}
 
 	return 0;
-
-dis_clks:
-	clk_disable_unprepare(spifi->clk_spifi);
-dis_clk_reg:
-	clk_disable_unprepare(spifi->clk_reg);
-	return ret;
 }
 
 static int nxp_spifi_remove(struct platform_device *pdev)
@@ -455,8 +436,6 @@ static int nxp_spifi_remove(struct platform_device *pdev)
 	struct nxp_spifi *spifi = platform_get_drvdata(pdev);
 
 	mtd_device_unregister(&spifi->nor.mtd);
-	clk_disable_unprepare(spifi->clk_spifi);
-	clk_disable_unprepare(spifi->clk_reg);
 
 	return 0;
 }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH -next 03/11] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()
  2023-08-17  2:45 ` [PATCH -next 03/11] mtd: rawnand: fsmc: " Li Zetao
@ 2023-08-17  8:31   ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-17  8:31 UTC (permalink / raw)
  To: Li Zetao
  Cc: richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li, robh, martin.blumenstingl, philmd,
	geert+renesas, u.kleine-koenig, rogerq, paul, nicolas.ferre,
	yangyingliang, dmitry.torokhov, heiko, christophe.leroy,
	christophe.kerello, jinpu.wang, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

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


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next 07/11] mtd: rawnand: mtk: Use helper function devm_clk_get_enabled()
  2023-08-17  2:45 ` [PATCH -next 07/11] mtd: rawnand: mtk: " Li Zetao
@ 2023-08-17  8:34   ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-17  8:34 UTC (permalink / raw)
  To: Li Zetao
  Cc: richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li, robh, martin.blumenstingl, philmd,
	geert+renesas, u.kleine-koenig, rogerq, paul, nicolas.ferre,
	yangyingliang, dmitry.torokhov, heiko, christophe.leroy,
	christophe.kerello, jinpu.wang, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

Hi Li,

lizetao1@huawei.com wrote on Thu, 17 Aug 2023 10:45:05 +0800:

> 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. The mtk_nfc_enable_clk() is a helper function that enables
> the "clk->nfi_clk" and "clk->pad_clk", it can be combined into
> devm_clk_get_enabled().
> 
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---
>  drivers/mtd/nand/raw/mtk_nand.c | 20 ++++++--------------
>  1 file changed, 6 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c
> index b6eb8cb6b5e9..0d185e650aaf 100644
> --- a/drivers/mtd/nand/raw/mtk_nand.c
> +++ b/drivers/mtd/nand/raw/mtk_nand.c
> @@ -1545,40 +1545,36 @@ static int mtk_nfc_probe(struct platform_device *pdev)
>  		goto release_ecc;
>  	}
>  
> -	nfc->clk.nfi_clk = devm_clk_get(dev, "nfi_clk");
> +	nfc->clk.nfi_clk = devm_clk_get_enabled(dev, "nfi_clk");
>  	if (IS_ERR(nfc->clk.nfi_clk)) {
>  		dev_err(dev, "no clk\n");
>  		ret = PTR_ERR(nfc->clk.nfi_clk);
>  		goto release_ecc;
>  	}
>  
> -	nfc->clk.pad_clk = devm_clk_get(dev, "pad_clk");
> +	nfc->clk.pad_clk = devm_clk_get_enabled(dev, "pad_clk");
>  	if (IS_ERR(nfc->clk.pad_clk)) {
>  		dev_err(dev, "no pad clk\n");
>  		ret = PTR_ERR(nfc->clk.pad_clk);
>  		goto release_ecc;
>  	}
>  
> -	ret = mtk_nfc_enable_clk(dev, &nfc->clk);
> -	if (ret)
> -		goto release_ecc;
> -
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		ret = -EINVAL;
> -		goto clk_disable;
> +		goto release_ecc;
>  	}
>  
>  	ret = devm_request_irq(dev, irq, mtk_nfc_irq, 0x0, "mtk-nand", nfc);
>  	if (ret) {
>  		dev_err(dev, "failed to request nfi irq\n");
> -		goto clk_disable;
> +		goto release_ecc;
>  	}
>  
>  	ret = dma_set_mask(dev, DMA_BIT_MASK(32));
>  	if (ret) {
>  		dev_err(dev, "failed to set dma mask\n");
> -		goto clk_disable;
> +		goto release_ecc;
>  	}
>  
>  	platform_set_drvdata(pdev, nfc);
> @@ -1586,14 +1582,11 @@ static int mtk_nfc_probe(struct platform_device *pdev)
>  	ret = mtk_nfc_nand_chips_init(dev, nfc);
>  	if (ret) {
>  		dev_err(dev, "failed to init nand chips\n");
> -		goto clk_disable;
> +		goto release_ecc;
>  	}
>  
>  	return 0;
>  
> -clk_disable:
> -	mtk_nfc_disable_clk(&nfc->clk);
> -
>  release_ecc:
>  	mtk_ecc_release(nfc->ecc);
>  
> @@ -1618,7 +1611,6 @@ static void mtk_nfc_remove(struct platform_device *pdev)
>  	}
>  
>  	mtk_ecc_release(nfc->ecc);
> -	mtk_nfc_disable_clk(&nfc->clk);

mtk_nfc_disable_clk() now has a single user, which is the suspend
callback. This callback does nothing else than calling
mtk_nfs_disable_clk(). Can you please drop the helper and just move the
two lines in the suspend function?

>  }
>  
>  #ifdef CONFIG_PM_SLEEP


Thanks,
Miquèl


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next 11/11] mtd: spi-nor: Use helper function devm_clk_get_enabled()
  2023-08-17  2:45 ` [PATCH -next 11/11] mtd: spi-nor: " Li Zetao
@ 2023-08-17  8:37   ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-17  8:37 UTC (permalink / raw)
  To: Li Zetao
  Cc: richard, vigneshr, michal.simek, vz, matthias.bgg,
	angelogioacchino.delregno, mcoquelin.stm32, alexandre.torgue,
	wens, jernej.skrabec, samuel, stefan, tudor.ambarus, pratyush,
	michael, frank.li, robh, martin.blumenstingl, philmd,
	geert+renesas, u.kleine-koenig, rogerq, paul, nicolas.ferre,
	yangyingliang, dmitry.torokhov, heiko, christophe.leroy,
	christophe.kerello, jinpu.wang, linux-mtd, linux-arm-kernel,
	linux-mediatek, linux-stm32, linux-sunxi

Hi Li,

lizetao1@huawei.com wrote on Thu, 17 Aug 2023 10:45:09 +0800:

> 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>

With the commit log corrected as suggested in another answer,

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers.
  2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
                   ` (10 preceding siblings ...)
  2023-08-17  2:45 ` [PATCH -next 11/11] mtd: spi-nor: " Li Zetao
@ 2023-08-18  7:46 ` Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
                     ` (12 more replies)
  11 siblings, 13 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

Commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
and enabled clocks") provides a new helper function for prepared and
enabled clocks when a driver keeps a clock prepared (or enabled) during
the whole lifetime of the driver. So where drivers get clocks and enable
them immediately, it can be combined into a single function
devm_clk_get_*(). Moreover, the unprepare and disable function
has been registered to devm_clk_state, and before devm_clk_state is
released, the clocks will be unprepareed and disable, so it is unnecessary
to unprepare and disable clock explicitly when remove drivers or in the
error handling path.

Change log:

v2:
 - Modify the format of the reference commit, use "since" instead of
 "after".
 - Drop the helper functions mtk_nfc_enable_clk() and
 mtk_nfc_disable_clk(), because both of them now have a single user.
 - Add a new patch, replace devm_clk_get_optional() +
 clk_prepare_enable() with devm_clk_get_optional_enabled().

v1: https://lore.kernel.org/all/20230817024509.3951629-1-lizetao1@huawei.com/

Li Zetao (12):
  mtd: spear_smi: Use helper function devm_clk_get_enabled()
  mtd: rawnand: arasan: Use helper function devm_clk_get_enabled()
  mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()
  mtd: rawnand: intel: Use helper function devm_clk_get_enabled()
  mtd: rawnand: lpc32xx_slc: Use helper function devm_clk_get_enabled()
  mtd: rawnand: mpc5121: Use helper function devm_clk_get_enabled()
  mtd: rawnand: mtk: Use helper function devm_clk_get_enabled()
  mtd: rawnand: stm32_fmc2: Use helper function devm_clk_get_enabled()
  mtd: rawnand: sunxi: Use helper function devm_clk_get_enabled()
  mtd: rawnand: vf610_nfc: Use helper function devm_clk_get_enabled()
  mtd: spi-nor: nxp-spifi: Use helper function devm_clk_get_enabled()
  mtd: rawnand: orion: Use helper function
    devm_clk_get_optional_enabled()

 drivers/mtd/devices/spear_smi.c               | 15 +----
 drivers/mtd/nand/raw/arasan-nand-controller.c | 29 ++-------
 drivers/mtd/nand/raw/fsmc_nand.c              | 12 +---
 drivers/mtd/nand/raw/intel-nand-controller.c  | 15 +----
 drivers/mtd/nand/raw/lpc32xx_slc.c            | 12 +---
 drivers/mtd/nand/raw/mpc5121_nfc.c            | 11 +---
 drivers/mtd/nand/raw/mtk_nand.c               | 62 ++++++-------------
 drivers/mtd/nand/raw/orion_nand.c             | 22 ++-----
 drivers/mtd/nand/raw/stm32_fmc2_nand.c        | 17 ++---
 drivers/mtd/nand/raw/sunxi_nand.c             | 29 ++-------
 drivers/mtd/nand/raw/vf610_nfc.c              | 29 +++------
 drivers/mtd/spi-nor/controllers/nxp-spifi.c   | 33 ++--------
 12 files changed, 67 insertions(+), 219 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH -next v2 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 02/12] mtd: rawnand: arasan: " Li Zetao
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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 "err_irq".

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-2-lizetao1@huawei.com/

 drivers/mtd/devices/spear_smi.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index 93bca5225116..0a35e5236ae5 100644
--- a/drivers/mtd/devices/spear_smi.c
+++ b/drivers/mtd/devices/spear_smi.c
@@ -993,21 +993,17 @@ static int spear_smi_probe(struct platform_device *pdev)
 		dev->num_flashes = MAX_NUM_FLASH_CHIP;
 	}
 
-	dev->clk = devm_clk_get(&pdev->dev, NULL);
+	dev->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(dev->clk)) {
 		ret = PTR_ERR(dev->clk);
 		goto err;
 	}
 
-	ret = clk_prepare_enable(dev->clk);
-	if (ret)
-		goto err;
-
 	ret = devm_request_irq(&pdev->dev, irq, spear_smi_int_handler, 0,
 			       pdev->name, dev);
 	if (ret) {
 		dev_err(&dev->pdev->dev, "SMI IRQ allocation failed\n");
-		goto err_irq;
+		goto err;
 	}
 
 	mutex_init(&dev->lock);
@@ -1020,14 +1016,11 @@ static int spear_smi_probe(struct platform_device *pdev)
 		ret = spear_smi_setup_banks(pdev, i, pdata->np[i]);
 		if (ret) {
 			dev_err(&dev->pdev->dev, "bank setup failed\n");
-			goto err_irq;
+			goto err;
 		}
 	}
 
 	return 0;
-
-err_irq:
-	clk_disable_unprepare(dev->clk);
 err:
 	return ret;
 }
@@ -1056,8 +1049,6 @@ static int spear_smi_remove(struct platform_device *pdev)
 		WARN_ON(mtd_device_unregister(&flash->mtd));
 	}
 
-	clk_disable_unprepare(dev->clk);
-
 	return 0;
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 02/12] mtd: rawnand: arasan: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  8:10     ` Miquel Raynal
  2023-08-18  7:46   ` [PATCH -next v2 03/12] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled() Li Zetao
                     ` (10 subsequent siblings)
  12 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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 "disable_bus_clk" and "disable_controller_clk".

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-3-lizetao1@huawei.com/

 drivers/mtd/nand/raw/arasan-nand-controller.c | 29 ++++---------------
 1 file changed, 5 insertions(+), 24 deletions(-)

diff --git a/drivers/mtd/nand/raw/arasan-nand-controller.c b/drivers/mtd/nand/raw/arasan-nand-controller.c
index 906eef70cb6d..4621ec549cc7 100644
--- a/drivers/mtd/nand/raw/arasan-nand-controller.c
+++ b/drivers/mtd/nand/raw/arasan-nand-controller.c
@@ -1440,45 +1440,29 @@ static int anfc_probe(struct platform_device *pdev)
 
 	anfc_reset(nfc);
 
-	nfc->controller_clk = devm_clk_get(&pdev->dev, "controller");
+	nfc->controller_clk = devm_clk_get_enabled(&pdev->dev, "controller");
 	if (IS_ERR(nfc->controller_clk))
 		return PTR_ERR(nfc->controller_clk);
 
-	nfc->bus_clk = devm_clk_get(&pdev->dev, "bus");
+	nfc->bus_clk = devm_clk_get_enabled(&pdev->dev, "bus");
 	if (IS_ERR(nfc->bus_clk))
 		return PTR_ERR(nfc->bus_clk);
 
-	ret = clk_prepare_enable(nfc->controller_clk);
-	if (ret)
-		return ret;
-
-	ret = clk_prepare_enable(nfc->bus_clk);
-	if (ret)
-		goto disable_controller_clk;
-
 	ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
 	if (ret)
-		goto disable_bus_clk;
+		return ret;
 
 	ret = anfc_parse_cs(nfc);
 	if (ret)
-		goto disable_bus_clk;
+		return ret;
 
 	ret = anfc_chips_init(nfc);
 	if (ret)
-		goto disable_bus_clk;
+		return ret;
 
 	platform_set_drvdata(pdev, nfc);
 
 	return 0;
-
-disable_bus_clk:
-	clk_disable_unprepare(nfc->bus_clk);
-
-disable_controller_clk:
-	clk_disable_unprepare(nfc->controller_clk);
-
-	return ret;
 }
 
 static void anfc_remove(struct platform_device *pdev)
@@ -1486,9 +1470,6 @@ static void anfc_remove(struct platform_device *pdev)
 	struct arasan_nfc *nfc = platform_get_drvdata(pdev);
 
 	anfc_chips_cleanup(nfc);
-
-	clk_disable_unprepare(nfc->bus_clk);
-	clk_disable_unprepare(nfc->controller_clk);
 }
 
 static const struct of_device_id anfc_ids[] = {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 03/12] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 02/12] mtd: rawnand: arasan: " Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  8:11     ` Miquel Raynal
  2023-08-18  7:46   ` [PATCH -next v2 04/12] mtd: rawnand: intel: " Li Zetao
                     ` (9 subsequent siblings)
  12 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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. 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>
---
v1 -> v2: Modify commit message and rename the label "disable_clk" to "disable_fsmc"
v1: https://lore.kernel.org/all/20230817024509.3951629-4-lizetao1@huawei.com/

 drivers/mtd/nand/raw/fsmc_nand.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
index 7b4742420dfc..7d587284c9a5 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.
@@ -1111,7 +1107,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 		if (!host->read_dma_chan) {
 			dev_err(&pdev->dev, "Unable to get read dma channel\n");
 			ret = -ENODEV;
-			goto disable_clk;
+			goto disable_fsmc;
 		}
 		host->write_dma_chan = dma_request_channel(mask, filter, NULL);
 		if (!host->write_dma_chan) {
@@ -1155,9 +1151,8 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 release_dma_read_chan:
 	if (host->mode == USE_DMA_ACCESS)
 		dma_release_channel(host->read_dma_chan);
-disable_clk:
+disable_fsmc:
 	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);
 	}
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 04/12] mtd: rawnand: intel: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (2 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 03/12] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 05/12] mtd: rawnand: lpc32xx_slc: " Li Zetao
                     ` (8 subsequent siblings)
  12 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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 "err_disable_unprepare_clk".

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-5-lizetao1@huawei.com/

 drivers/mtd/nand/raw/intel-nand-controller.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/nand/raw/intel-nand-controller.c b/drivers/mtd/nand/raw/intel-nand-controller.c
index a9909eb08124..cb5d88f42297 100644
--- a/drivers/mtd/nand/raw/intel-nand-controller.c
+++ b/drivers/mtd/nand/raw/intel-nand-controller.c
@@ -626,16 +626,10 @@ static int ebu_nand_probe(struct platform_device *pdev)
 		goto err_of_node_put;
 	}
 
-	ebu_host->clk = devm_clk_get(dev, NULL);
+	ebu_host->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(ebu_host->clk)) {
 		ret = dev_err_probe(dev, PTR_ERR(ebu_host->clk),
-				    "failed to get clock\n");
-		goto err_of_node_put;
-	}
-
-	ret = clk_prepare_enable(ebu_host->clk);
-	if (ret) {
-		dev_err(dev, "failed to enable clock: %d\n", ret);
+				    "failed to get and enable clock\n");
 		goto err_of_node_put;
 	}
 
@@ -643,7 +637,7 @@ static int ebu_nand_probe(struct platform_device *pdev)
 	if (IS_ERR(ebu_host->dma_tx)) {
 		ret = dev_err_probe(dev, PTR_ERR(ebu_host->dma_tx),
 				    "failed to request DMA tx chan!.\n");
-		goto err_disable_unprepare_clk;
+		goto err_of_node_put;
 	}
 
 	ebu_host->dma_rx = dma_request_chan(dev, "rx");
@@ -698,8 +692,6 @@ static int ebu_nand_probe(struct platform_device *pdev)
 	nand_cleanup(&ebu_host->chip);
 err_cleanup_dma:
 	ebu_dma_cleanup(ebu_host);
-err_disable_unprepare_clk:
-	clk_disable_unprepare(ebu_host->clk);
 err_of_node_put:
 	of_node_put(chip_np);
 
@@ -716,7 +708,6 @@ static void ebu_nand_remove(struct platform_device *pdev)
 	nand_cleanup(&ebu_host->chip);
 	ebu_nand_disable(&ebu_host->chip);
 	ebu_dma_cleanup(ebu_host);
-	clk_disable_unprepare(ebu_host->clk);
 }
 
 static const struct of_device_id ebu_nand_match[] = {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 05/12] mtd: rawnand: lpc32xx_slc: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (3 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 04/12] mtd: rawnand: intel: " Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 06/12] mtd: rawnand: mpc5121: " Li Zetao
                     ` (7 subsequent siblings)
  12 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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 "unprepare_clk".

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-6-lizetao1@huawei.com/

 drivers/mtd/nand/raw/lpc32xx_slc.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c
index 2201264d3c37..1c5fa855b9f2 100644
--- a/drivers/mtd/nand/raw/lpc32xx_slc.c
+++ b/drivers/mtd/nand/raw/lpc32xx_slc.c
@@ -871,15 +871,12 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 	mtd->dev.parent = &pdev->dev;
 
 	/* Get NAND clock */
-	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, "Clock failure\n");
 		res = -ENOENT;
 		goto enable_wp;
 	}
-	res = clk_prepare_enable(host->clk);
-	if (res)
-		goto enable_wp;
 
 	/* Set NAND IO addresses and command/ready functions */
 	chip->legacy.IO_ADDR_R = SLC_DATA(host->io_base);
@@ -907,13 +904,13 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 				      GFP_KERNEL);
 	if (host->data_buf == NULL) {
 		res = -ENOMEM;
-		goto unprepare_clk;
+		goto enable_wp;
 	}
 
 	res = lpc32xx_nand_dma_setup(host);
 	if (res) {
 		res = -EIO;
-		goto unprepare_clk;
+		goto enable_wp;
 	}
 
 	/* Find NAND device */
@@ -934,8 +931,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 	nand_cleanup(chip);
 release_dma:
 	dma_release_channel(host->dma_chan);
-unprepare_clk:
-	clk_disable_unprepare(host->clk);
 enable_wp:
 	lpc32xx_wp_enable(host);
 
@@ -962,7 +957,6 @@ static void lpc32xx_nand_remove(struct platform_device *pdev)
 	tmp &= ~SLCCFG_CE_LOW;
 	writel(tmp, SLC_CTRL(host->io_base));
 
-	clk_disable_unprepare(host->clk);
 	lpc32xx_wp_enable(host);
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 06/12] mtd: rawnand: mpc5121: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (4 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 05/12] mtd: rawnand: lpc32xx_slc: " Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 07/12] mtd: rawnand: mtk: " Li Zetao
                     ` (6 subsequent siblings)
  12 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-7-lizetao1@huawei.com/

 drivers/mtd/nand/raw/mpc5121_nfc.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/mpc5121_nfc.c b/drivers/mtd/nand/raw/mpc5121_nfc.c
index 6e8e790f84e7..215610f808f1 100644
--- a/drivers/mtd/nand/raw/mpc5121_nfc.c
+++ b/drivers/mtd/nand/raw/mpc5121_nfc.c
@@ -595,8 +595,6 @@ static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd)
 	struct nand_chip *chip = mtd_to_nand(mtd);
 	struct mpc5121_nfc_prv *prv = nand_get_controller_data(chip);
 
-	clk_disable_unprepare(prv->clk);
-
 	if (prv->csreg)
 		iounmap(prv->csreg);
 }
@@ -717,17 +715,12 @@ static int mpc5121_nfc_probe(struct platform_device *op)
 	}
 
 	/* Enable NFC clock */
-	clk = devm_clk_get(dev, "ipg");
+	clk = devm_clk_get_enabled(dev, "ipg");
 	if (IS_ERR(clk)) {
-		dev_err(dev, "Unable to acquire NFC clock!\n");
+		dev_err(dev, "Unable to acquire and enable NFC clock!\n");
 		retval = PTR_ERR(clk);
 		goto error;
 	}
-	retval = clk_prepare_enable(clk);
-	if (retval) {
-		dev_err(dev, "Unable to enable NFC clock!\n");
-		goto error;
-	}
 	prv->clk = clk;
 
 	/* Reset NAND Flash controller */
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 07/12] mtd: rawnand: mtk: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (5 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 06/12] mtd: rawnand: mpc5121: " Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 08/12] mtd: rawnand: stm32_fmc2: " Li Zetao
                     ` (5 subsequent siblings)
  12 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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 "clk_disable". And both mtk_nfc_enable_clk() and
mtk_nfc_disable_clk() now have a single user, which is the resume or
suspend callback, so drop this two helper function and just move related
operations in the resume or suspend function.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Modify commit message and drop two helper functions
mtk_nfc_enable_clk() and mtk_nfc_disable_clk().
v1: https://lore.kernel.org/all/20230817024509.3951629-8-lizetao1@huawei.com/

 drivers/mtd/nand/raw/mtk_nand.c | 62 ++++++++++-----------------------
 1 file changed, 19 insertions(+), 43 deletions(-)

diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c
index b6eb8cb6b5e9..29c8bddde67f 100644
--- a/drivers/mtd/nand/raw/mtk_nand.c
+++ b/drivers/mtd/nand/raw/mtk_nand.c
@@ -1118,32 +1118,6 @@ static irqreturn_t mtk_nfc_irq(int irq, void *id)
 	return IRQ_HANDLED;
 }
 
-static int mtk_nfc_enable_clk(struct device *dev, struct mtk_nfc_clk *clk)
-{
-	int ret;
-
-	ret = clk_prepare_enable(clk->nfi_clk);
-	if (ret) {
-		dev_err(dev, "failed to enable nfi clk\n");
-		return ret;
-	}
-
-	ret = clk_prepare_enable(clk->pad_clk);
-	if (ret) {
-		dev_err(dev, "failed to enable pad clk\n");
-		clk_disable_unprepare(clk->nfi_clk);
-		return ret;
-	}
-
-	return 0;
-}
-
-static void mtk_nfc_disable_clk(struct mtk_nfc_clk *clk)
-{
-	clk_disable_unprepare(clk->nfi_clk);
-	clk_disable_unprepare(clk->pad_clk);
-}
-
 static int mtk_nfc_ooblayout_free(struct mtd_info *mtd, int section,
 				  struct mtd_oob_region *oob_region)
 {
@@ -1545,40 +1519,36 @@ static int mtk_nfc_probe(struct platform_device *pdev)
 		goto release_ecc;
 	}
 
-	nfc->clk.nfi_clk = devm_clk_get(dev, "nfi_clk");
+	nfc->clk.nfi_clk = devm_clk_get_enabled(dev, "nfi_clk");
 	if (IS_ERR(nfc->clk.nfi_clk)) {
 		dev_err(dev, "no clk\n");
 		ret = PTR_ERR(nfc->clk.nfi_clk);
 		goto release_ecc;
 	}
 
-	nfc->clk.pad_clk = devm_clk_get(dev, "pad_clk");
+	nfc->clk.pad_clk = devm_clk_get_enabled(dev, "pad_clk");
 	if (IS_ERR(nfc->clk.pad_clk)) {
 		dev_err(dev, "no pad clk\n");
 		ret = PTR_ERR(nfc->clk.pad_clk);
 		goto release_ecc;
 	}
 
-	ret = mtk_nfc_enable_clk(dev, &nfc->clk);
-	if (ret)
-		goto release_ecc;
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		ret = -EINVAL;
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	ret = devm_request_irq(dev, irq, mtk_nfc_irq, 0x0, "mtk-nand", nfc);
 	if (ret) {
 		dev_err(dev, "failed to request nfi irq\n");
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	ret = dma_set_mask(dev, DMA_BIT_MASK(32));
 	if (ret) {
 		dev_err(dev, "failed to set dma mask\n");
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	platform_set_drvdata(pdev, nfc);
@@ -1586,14 +1556,11 @@ static int mtk_nfc_probe(struct platform_device *pdev)
 	ret = mtk_nfc_nand_chips_init(dev, nfc);
 	if (ret) {
 		dev_err(dev, "failed to init nand chips\n");
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	return 0;
 
-clk_disable:
-	mtk_nfc_disable_clk(&nfc->clk);
-
 release_ecc:
 	mtk_ecc_release(nfc->ecc);
 
@@ -1618,7 +1585,6 @@ static void mtk_nfc_remove(struct platform_device *pdev)
 	}
 
 	mtk_ecc_release(nfc->ecc);
-	mtk_nfc_disable_clk(&nfc->clk);
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -1626,7 +1592,8 @@ static int mtk_nfc_suspend(struct device *dev)
 {
 	struct mtk_nfc *nfc = dev_get_drvdata(dev);
 
-	mtk_nfc_disable_clk(&nfc->clk);
+	clk_disable_unprepare(nfc->clk.nfi_clk);
+	clk_disable_unprepare(nfc->clk.pad_clk);
 
 	return 0;
 }
@@ -1641,9 +1608,18 @@ static int mtk_nfc_resume(struct device *dev)
 
 	udelay(200);
 
-	ret = mtk_nfc_enable_clk(dev, &nfc->clk);
-	if (ret)
+	ret = clk_prepare_enable(nfc->clk.nfi_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable nfi clk\n");
 		return ret;
+	}
+
+	ret = clk_prepare_enable(nfc->clk.pad_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable pad clk\n");
+		clk_disable_unprepare(nfc->clk.nfi_clk);
+		return ret;
+	}
 
 	/* reset NAND chip if VCC was powered off */
 	list_for_each_entry(chip, &nfc->chips, node) {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 08/12] mtd: rawnand: stm32_fmc2: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (6 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 07/12] mtd: rawnand: mtk: " Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 09/12] mtd: rawnand: sunxi: " Li Zetao
                     ` (4 subsequent siblings)
  12 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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 "err_clk_disable".

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-9-lizetao1@huawei.com/

 drivers/mtd/nand/raw/stm32_fmc2_nand.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
index 2f9e43f64dd7..88811139aaf5 100644
--- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
+++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
@@ -1951,21 +1951,17 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
 
 	init_completion(&nfc->complete);
 
-	nfc->clk = devm_clk_get(nfc->cdev, NULL);
-	if (IS_ERR(nfc->clk))
+	nfc->clk = devm_clk_get_enabled(nfc->cdev, NULL);
+	if (IS_ERR(nfc->clk)) {
+		dev_err(dev, "can not get and enable the clock\n");
 		return PTR_ERR(nfc->clk);
-
-	ret = clk_prepare_enable(nfc->clk);
-	if (ret) {
-		dev_err(dev, "can not enable the clock\n");
-		return ret;
 	}
 
 	rstc = devm_reset_control_get(dev, NULL);
 	if (IS_ERR(rstc)) {
 		ret = PTR_ERR(rstc);
 		if (ret == -EPROBE_DEFER)
-			goto err_clk_disable;
+			return ret;
 	} else {
 		reset_control_assert(rstc);
 		reset_control_deassert(rstc);
@@ -2018,9 +2014,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
 	sg_free_table(&nfc->dma_data_sg);
 	sg_free_table(&nfc->dma_ecc_sg);
 
-err_clk_disable:
-	clk_disable_unprepare(nfc->clk);
-
 	return ret;
 }
 
@@ -2045,8 +2038,6 @@ static void stm32_fmc2_nfc_remove(struct platform_device *pdev)
 	sg_free_table(&nfc->dma_data_sg);
 	sg_free_table(&nfc->dma_ecc_sg);
 
-	clk_disable_unprepare(nfc->clk);
-
 	stm32_fmc2_nfc_wp_enable(nand);
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 09/12] mtd: rawnand: sunxi: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (7 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 08/12] mtd: rawnand: stm32_fmc2: " Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 10/12] mtd: rawnand: vf610_nfc: " Li Zetao
                     ` (3 subsequent siblings)
  12 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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 "out_mod_clk_unprepare" and "out_ahb_clk_unprepare".

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-10-lizetao1@huawei.com/

 drivers/mtd/nand/raw/sunxi_nand.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 64c09eae951d..9abf38049d35 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -2094,37 +2094,26 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	nfc->ahb_clk = devm_clk_get(dev, "ahb");
+	nfc->ahb_clk = devm_clk_get_enabled(dev, "ahb");
 	if (IS_ERR(nfc->ahb_clk)) {
 		dev_err(dev, "failed to retrieve ahb clk\n");
 		return PTR_ERR(nfc->ahb_clk);
 	}
 
-	ret = clk_prepare_enable(nfc->ahb_clk);
-	if (ret)
-		return ret;
-
-	nfc->mod_clk = devm_clk_get(dev, "mod");
+	nfc->mod_clk = devm_clk_get_enabled(dev, "mod");
 	if (IS_ERR(nfc->mod_clk)) {
 		dev_err(dev, "failed to retrieve mod clk\n");
-		ret = PTR_ERR(nfc->mod_clk);
-		goto out_ahb_clk_unprepare;
+		return PTR_ERR(nfc->mod_clk);
 	}
 
-	ret = clk_prepare_enable(nfc->mod_clk);
-	if (ret)
-		goto out_ahb_clk_unprepare;
-
 	nfc->reset = devm_reset_control_get_optional_exclusive(dev, "ahb");
-	if (IS_ERR(nfc->reset)) {
-		ret = PTR_ERR(nfc->reset);
-		goto out_mod_clk_unprepare;
-	}
+	if (IS_ERR(nfc->reset))
+		return PTR_ERR(nfc->reset);
 
 	ret = reset_control_deassert(nfc->reset);
 	if (ret) {
 		dev_err(dev, "reset err %d\n", ret);
-		goto out_mod_clk_unprepare;
+		return ret;
 	}
 
 	nfc->caps = of_device_get_match_data(&pdev->dev);
@@ -2163,10 +2152,6 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
 		dma_release_channel(nfc->dmac);
 out_ahb_reset_reassert:
 	reset_control_assert(nfc->reset);
-out_mod_clk_unprepare:
-	clk_disable_unprepare(nfc->mod_clk);
-out_ahb_clk_unprepare:
-	clk_disable_unprepare(nfc->ahb_clk);
 
 	return ret;
 }
@@ -2181,8 +2166,6 @@ static void sunxi_nfc_remove(struct platform_device *pdev)
 
 	if (nfc->dmac)
 		dma_release_channel(nfc->dmac);
-	clk_disable_unprepare(nfc->mod_clk);
-	clk_disable_unprepare(nfc->ahb_clk);
 }
 
 static const struct sunxi_nfc_caps sunxi_nfc_a10_caps = {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 10/12] mtd: rawnand: vf610_nfc: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (8 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 09/12] mtd: rawnand: sunxi: " Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18  7:46   ` [PATCH -next v2 11/12] mtd: spi-nor: nxp-spifi: " Li Zetao
                     ` (2 subsequent siblings)
  12 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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 "err_disable_clk".

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-11-lizetao1@huawei.com/

 drivers/mtd/nand/raw/vf610_nfc.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
index dcdf33dbaef2..1ce9d5c2b1f7 100644
--- a/drivers/mtd/nand/raw/vf610_nfc.c
+++ b/drivers/mtd/nand/raw/vf610_nfc.c
@@ -834,21 +834,15 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 	if (IS_ERR(nfc->regs))
 		return PTR_ERR(nfc->regs);
 
-	nfc->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(nfc->clk))
+	nfc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
+	if (IS_ERR(nfc->clk)) {
+		dev_err(nfc->dev, "Unable to get and enable clock!\n");
 		return PTR_ERR(nfc->clk);
-
-	err = clk_prepare_enable(nfc->clk);
-	if (err) {
-		dev_err(nfc->dev, "Unable to enable clock!\n");
-		return err;
 	}
 
 	of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev);
-	if (!of_id) {
-		err = -ENODEV;
-		goto err_disable_clk;
-	}
+	if (!of_id)
+		return -ENODEV;
 
 	nfc->variant = (enum vf610_nfc_variant)of_id->data;
 
@@ -858,9 +852,8 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 			if (nand_get_flash_node(chip)) {
 				dev_err(nfc->dev,
 					"Only one NAND chip supported!\n");
-				err = -EINVAL;
 				of_node_put(child);
-				goto err_disable_clk;
+				return -EINVAL;
 			}
 
 			nand_set_flash_node(chip, child);
@@ -869,8 +862,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 
 	if (!nand_get_flash_node(chip)) {
 		dev_err(nfc->dev, "NAND chip sub-node missing!\n");
-		err = -ENODEV;
-		goto err_disable_clk;
+		return -ENODEV;
 	}
 
 	chip->options |= NAND_NO_SUBPAGE_WRITE;
@@ -880,7 +872,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 	err = devm_request_irq(nfc->dev, irq, vf610_nfc_irq, 0, DRV_NAME, nfc);
 	if (err) {
 		dev_err(nfc->dev, "Error requesting IRQ!\n");
-		goto err_disable_clk;
+		return err;
 	}
 
 	vf610_nfc_preinit_controller(nfc);
@@ -892,7 +884,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 	/* Scan the NAND chip */
 	err = nand_scan(chip, 1);
 	if (err)
-		goto err_disable_clk;
+		return err;
 
 	platform_set_drvdata(pdev, nfc);
 
@@ -904,8 +896,6 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 
 err_cleanup_nand:
 	nand_cleanup(chip);
-err_disable_clk:
-	clk_disable_unprepare(nfc->clk);
 	return err;
 }
 
@@ -918,7 +908,6 @@ static void vf610_nfc_remove(struct platform_device *pdev)
 	ret = mtd_device_unregister(nand_to_mtd(chip));
 	WARN_ON(ret);
 	nand_cleanup(chip);
-	clk_disable_unprepare(nfc->clk);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 11/12] mtd: spi-nor: nxp-spifi: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (9 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 10/12] mtd: rawnand: vf610_nfc: " Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18 10:19     ` Tudor Ambarus
  2023-08-18  7:46   ` [PATCH -next v2 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled() Li Zetao
  2023-08-18 10:28   ` (subset) [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Tudor Ambarus
  12 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

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 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>
---
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-12-lizetao1@huawei.com/

 drivers/mtd/spi-nor/controllers/nxp-spifi.c | 33 ++++-----------------
 1 file changed, 6 insertions(+), 27 deletions(-)

diff --git a/drivers/mtd/spi-nor/controllers/nxp-spifi.c b/drivers/mtd/spi-nor/controllers/nxp-spifi.c
index 337e83bf3362..5d8f47ab146f 100644
--- a/drivers/mtd/spi-nor/controllers/nxp-spifi.c
+++ b/drivers/mtd/spi-nor/controllers/nxp-spifi.c
@@ -394,30 +394,18 @@ static int nxp_spifi_probe(struct platform_device *pdev)
 	if (IS_ERR(spifi->flash_base))
 		return PTR_ERR(spifi->flash_base);
 
-	spifi->clk_spifi = devm_clk_get(&pdev->dev, "spifi");
+	spifi->clk_spifi = devm_clk_get_enabled(&pdev->dev, "spifi");
 	if (IS_ERR(spifi->clk_spifi)) {
-		dev_err(&pdev->dev, "spifi clock not found\n");
+		dev_err(&pdev->dev, "spifi clock not found or unable to enable\n");
 		return PTR_ERR(spifi->clk_spifi);
 	}
 
-	spifi->clk_reg = devm_clk_get(&pdev->dev, "reg");
+	spifi->clk_reg = devm_clk_get_enabled(&pdev->dev, "reg");
 	if (IS_ERR(spifi->clk_reg)) {
-		dev_err(&pdev->dev, "reg clock not found\n");
+		dev_err(&pdev->dev, "reg clock not found or unable to enable\n");
 		return PTR_ERR(spifi->clk_reg);
 	}
 
-	ret = clk_prepare_enable(spifi->clk_reg);
-	if (ret) {
-		dev_err(&pdev->dev, "unable to enable reg clock\n");
-		return ret;
-	}
-
-	ret = clk_prepare_enable(spifi->clk_spifi);
-	if (ret) {
-		dev_err(&pdev->dev, "unable to enable spifi clock\n");
-		goto dis_clk_reg;
-	}
-
 	spifi->dev = &pdev->dev;
 	platform_set_drvdata(pdev, spifi);
 
@@ -430,24 +418,17 @@ static int nxp_spifi_probe(struct platform_device *pdev)
 	flash_np = of_get_next_available_child(pdev->dev.of_node, NULL);
 	if (!flash_np) {
 		dev_err(&pdev->dev, "no SPI flash device to configure\n");
-		ret = -ENODEV;
-		goto dis_clks;
+		return -ENODEV;
 	}
 
 	ret = nxp_spifi_setup_flash(spifi, flash_np);
 	of_node_put(flash_np);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to setup flash chip\n");
-		goto dis_clks;
+		return ret;
 	}
 
 	return 0;
-
-dis_clks:
-	clk_disable_unprepare(spifi->clk_spifi);
-dis_clk_reg:
-	clk_disable_unprepare(spifi->clk_reg);
-	return ret;
 }
 
 static int nxp_spifi_remove(struct platform_device *pdev)
@@ -455,8 +436,6 @@ static int nxp_spifi_remove(struct platform_device *pdev)
 	struct nxp_spifi *spifi = platform_get_drvdata(pdev);
 
 	mtd_device_unregister(&spifi->nor.mtd);
-	clk_disable_unprepare(spifi->clk_spifi);
-	clk_disable_unprepare(spifi->clk_reg);
 
 	return 0;
 }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v2 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled()
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (10 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 11/12] mtd: spi-nor: nxp-spifi: " Li Zetao
@ 2023-08-18  7:46   ` Li Zetao
  2023-08-18 10:28   ` (subset) [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Tudor Ambarus
  12 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-18  7:46 UTC (permalink / raw)
  To: lizetao1
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, tudor.ambarus,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
and enabled clocks"), devm_clk_get_optional() and clk_prepare_enable() can
now be replaced by devm_clk_get_optional_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 "no_dev".

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: This is a new patch.

 drivers/mtd/nand/raw/orion_nand.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/mtd/nand/raw/orion_nand.c b/drivers/mtd/nand/raw/orion_nand.c
index 7e0313889b50..2951d81614fd 100644
--- a/drivers/mtd/nand/raw/orion_nand.c
+++ b/drivers/mtd/nand/raw/orion_nand.c
@@ -169,16 +169,10 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, info);
 
 	/* Not all platforms can gate the clock, so it is optional. */
-	info->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	info->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
 	if (IS_ERR(info->clk))
 		return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
-				     "failed to get clock!\n");
-
-	ret = clk_prepare_enable(info->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to prepare clock!\n");
-		return ret;
-	}
+				     "failed to get and enable clock!\n");
 
 	/*
 	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
@@ -189,19 +183,13 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 
 	ret = nand_scan(nc, 1);
 	if (ret)
-		goto no_dev;
+		return ret;
 
 	mtd->name = "orion_nand";
 	ret = mtd_device_register(mtd, board->parts, board->nr_parts);
-	if (ret) {
+	if (ret)
 		nand_cleanup(nc);
-		goto no_dev;
-	}
-
-	return 0;
 
-no_dev:
-	clk_disable_unprepare(info->clk);
 	return ret;
 }
 
@@ -215,8 +203,6 @@ static void orion_nand_remove(struct platform_device *pdev)
 	WARN_ON(ret);
 
 	nand_cleanup(chip);
-
-	clk_disable_unprepare(info->clk);
 }
 
 #ifdef CONFIG_OF
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v2 02/12] mtd: rawnand: arasan: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46   ` [PATCH -next v2 02/12] mtd: rawnand: arasan: " Li Zetao
@ 2023-08-18  8:10     ` Miquel Raynal
  2023-08-18  8:12       ` Miquel Raynal
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  0 siblings, 2 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-18  8:10 UTC (permalink / raw)
  To: Li Zetao
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, nicolas.ferre, paul, philmd, pratyush, richard,
	robh, rogerq, samuel, stefan, tudor.ambarus, u.kleine-koenig,
	vigneshr, vz, wens, yangyingliang

Hi Li,

lizetao1@huawei.com wrote on Fri, 18 Aug 2023 15:46:32 +0800:

> 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 enable (and possibly

For all the commit logs:		  the driver enables (and possibly prepares)

> 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

For all the commit logs:		       the clocks

The ",so drop the label xxx" is not needed I believe.

> the label "disable_bus_clk" and "disable_controller_clk".
> 
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---

Thanks,
Miquèl


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v2 03/12] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46   ` [PATCH -next v2 03/12] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-18  8:11     ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-18  8:11 UTC (permalink / raw)
  To: Li Zetao
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, nicolas.ferre, paul, philmd, pratyush, richard,
	robh, rogerq, samuel, stefan, tudor.ambarus, u.kleine-koenig,
	vigneshr, vz, wens, yangyingliang

Hi Li,

lizetao1@huawei.com wrote on Fri, 18 Aug 2023 15:46:33 +0800:

> 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 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. The
> label "disable_clk" no longer makes sense, rename it to "disable_fsmc".

Yep, please keep this last sentence here, it is useful.

> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---

Thanks,
Miquèl


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v2 02/12] mtd: rawnand: arasan: Use helper function devm_clk_get_enabled()
  2023-08-18  8:10     ` Miquel Raynal
@ 2023-08-18  8:12       ` Miquel Raynal
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  1 sibling, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-18  8:12 UTC (permalink / raw)
  To: Li Zetao
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, nicolas.ferre, paul, philmd, pratyush, richard,
	robh, rogerq, samuel, stefan, tudor.ambarus, u.kleine-koenig,
	vigneshr, vz, wens, yangyingliang


miquel.raynal@bootlin.com wrote on Fri, 18 Aug 2023 10:10:04 +0200:

> Hi Li,
> 
> lizetao1@huawei.com wrote on Fri, 18 Aug 2023 15:46:32 +0800:
> 
> > 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 enable (and possibly  
> 
> For all the commit logs:		  the driver enables (and possibly prepares)
> 
> > 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  
> 
> For all the commit logs:		       the clocks
> 
> The ",so drop the label xxx" is not needed I believe.
> 
> > the label "disable_bus_clk" and "disable_controller_clk".

Actually it does not bother, just keep it.

> > Signed-off-by: Li Zetao <lizetao1@huawei.com>
> > ---  
> 
> Thanks,
> Miquèl


Thanks,
Miquèl


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v2 11/12] mtd: spi-nor: nxp-spifi: Use helper function devm_clk_get_enabled()
  2023-08-18  7:46   ` [PATCH -next v2 11/12] mtd: spi-nor: nxp-spifi: " Li Zetao
@ 2023-08-18 10:19     ` Tudor Ambarus
  0 siblings, 0 replies; 58+ messages in thread
From: Tudor Ambarus @ 2023-08-18 10:19 UTC (permalink / raw)
  To: Li Zetao
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, miquel.raynal, nicolas.ferre, paul, philmd,
	pratyush, richard, robh, rogerq, samuel, stefan, u.kleine-koenig,
	vigneshr, vz, wens, yangyingliang

Just a reminder that for the owners of the driver that we'd like to move
all the SPI NOR controller drivers to drivers/spi and that until then
we'll no longer queue features for the controllers, but just fixes or
cosmetics patches like this one.

Cheers,
ta


^ permalink raw reply	[flat|nested] 58+ messages in thread

* (subset) [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers.
  2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                     ` (11 preceding siblings ...)
  2023-08-18  7:46   ` [PATCH -next v2 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled() Li Zetao
@ 2023-08-18 10:28   ` Tudor Ambarus
  12 siblings, 0 replies; 58+ messages in thread
From: Tudor Ambarus @ 2023-08-18 10:28 UTC (permalink / raw)
  To: Li Zetao
  Cc: Tudor Ambarus, alexandre.torgue, angelogioacchino.delregno,
	christophe.kerello, christophe.leroy, dmitry.torokhov, frank.li,
	geert+renesas, heiko, jernej.skrabec, jinpu.wang,
	linux-arm-kernel, linux-mediatek, linux-mtd, linux-stm32,
	linux-sunxi, martin.blumenstingl, matthias.bgg, mcoquelin.stm32,
	michael, michal.simek, miquel.raynal, nicolas.ferre, paul,
	philmd, pratyush, richard, robh, rogerq, samuel, stefan,
	u.kleine-koenig, vigneshr, vz, wens, yangyingliang

On Fri, 18 Aug 2023 15:46:30 +0800, Li Zetao wrote:
> Commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
> and enabled clocks") provides a new helper function for prepared and
> enabled clocks when a driver keeps a clock prepared (or enabled) during
> the whole lifetime of the driver. So where drivers get clocks and enable
> them immediately, it can be combined into a single function
> devm_clk_get_*(). Moreover, the unprepare and disable function
> has been registered to devm_clk_state, and before devm_clk_state is
> released, the clocks will be unprepareed and disable, so it is unnecessary
> to unprepare and disable clock explicitly when remove drivers or in the
> error handling path.
> 
> [...]

Applied to git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git,
spi-nor/next branch. Thanks!

[11/12] mtd: spi-nor: nxp-spifi: Use helper function devm_clk_get_enabled()
        https://git.kernel.org/mtd/c/69d50d0461a1

Cheers,
-- 
Tudor Ambarus <tudor.ambarus@linaro.org>


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers.
  2023-08-18  8:10     ` Miquel Raynal
  2023-08-18  8:12       ` Miquel Raynal
@ 2023-08-21  3:17       ` Li Zetao
  2023-08-21  3:17         ` [PATCH -next v3 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
                           ` (11 more replies)
  1 sibling, 12 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

Commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
and enabled clocks") provides a new helper function for prepared and
enabled clocks when a driver keeps a clock prepared (or enabled) during
the whole lifetime of the driver. So where drivers get clocks and enable
them immediately, it can be combined into a single function
devm_clk_get_*(). Moreover, the unprepare and disable function
has been registered to devm_clk_state, and before devm_clk_state is
released, the clocks will be unprepareed and disable, so it is unnecessary
to unprepare and disable clocks explicitly when remove drivers or in the
error handling path.

Change log:

v3:
 - Modify the syntax error in the commit message.

v2: https://lore.kernel.org/all/20230818074642.308166-1-lizetao1@huawei.com
 - Modify the format of the reference commit, use "since" instead of
 "after".
 - Drop the helper functions mtk_nfc_enable_clk() and
 mtk_nfc_disable_clk(), because both of them now have a single user.
 - Add a new patch, replace devm_clk_get_optional() +
 clk_prepare_enable() with devm_clk_get_optional_enabled().

v1: https://lore.kernel.org/all/20230817024509.3951629-1-lizetao1@huawei.com

Li Zetao (12):
  mtd: spear_smi: Use helper function devm_clk_get_enabled()
  mtd: rawnand: arasan: Use helper function devm_clk_get_enabled()
  mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()
  mtd: rawnand: intel: Use helper function devm_clk_get_enabled()
  mtd: rawnand: lpc32xx_slc: Use helper function devm_clk_get_enabled()
  mtd: rawnand: mpc5121: Use helper function devm_clk_get_enabled()
  mtd: rawnand: mtk: Use helper function devm_clk_get_enabled()
  mtd: rawnand: stm32_fmc2: Use helper function devm_clk_get_enabled()
  mtd: rawnand: sunxi: Use helper function devm_clk_get_enabled()
  mtd: rawnand: vf610_nfc: Use helper function devm_clk_get_enabled()
  mtd: spi-nor: nxp-spifi: Use helper function devm_clk_get_enabled()
  mtd: rawnand: orion: Use helper function
    devm_clk_get_optional_enabled()

 drivers/mtd/devices/spear_smi.c               | 15 +----
 drivers/mtd/nand/raw/arasan-nand-controller.c | 29 ++-------
 drivers/mtd/nand/raw/fsmc_nand.c              | 12 +---
 drivers/mtd/nand/raw/intel-nand-controller.c  | 15 +----
 drivers/mtd/nand/raw/lpc32xx_slc.c            | 12 +---
 drivers/mtd/nand/raw/mpc5121_nfc.c            | 11 +---
 drivers/mtd/nand/raw/mtk_nand.c               | 62 ++++++-------------
 drivers/mtd/nand/raw/orion_nand.c             | 22 ++-----
 drivers/mtd/nand/raw/stm32_fmc2_nand.c        | 17 ++---
 drivers/mtd/nand/raw/sunxi_nand.c             | 29 ++-------
 drivers/mtd/nand/raw/vf610_nfc.c              | 29 +++------
 drivers/mtd/spi-nor/controllers/nxp-spifi.c   | 33 ++--------
 12 files changed, 67 insertions(+), 219 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH -next v3 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:57           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 02/12] mtd: rawnand: arasan: " Li Zetao
                           ` (10 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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_irq".

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-2-lizetao1@huawei.com/
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-2-lizetao1@huawei.com/

 drivers/mtd/devices/spear_smi.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index 93bca5225116..0a35e5236ae5 100644
--- a/drivers/mtd/devices/spear_smi.c
+++ b/drivers/mtd/devices/spear_smi.c
@@ -993,21 +993,17 @@ static int spear_smi_probe(struct platform_device *pdev)
 		dev->num_flashes = MAX_NUM_FLASH_CHIP;
 	}
 
-	dev->clk = devm_clk_get(&pdev->dev, NULL);
+	dev->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(dev->clk)) {
 		ret = PTR_ERR(dev->clk);
 		goto err;
 	}
 
-	ret = clk_prepare_enable(dev->clk);
-	if (ret)
-		goto err;
-
 	ret = devm_request_irq(&pdev->dev, irq, spear_smi_int_handler, 0,
 			       pdev->name, dev);
 	if (ret) {
 		dev_err(&dev->pdev->dev, "SMI IRQ allocation failed\n");
-		goto err_irq;
+		goto err;
 	}
 
 	mutex_init(&dev->lock);
@@ -1020,14 +1016,11 @@ static int spear_smi_probe(struct platform_device *pdev)
 		ret = spear_smi_setup_banks(pdev, i, pdata->np[i]);
 		if (ret) {
 			dev_err(&dev->pdev->dev, "bank setup failed\n");
-			goto err_irq;
+			goto err;
 		}
 	}
 
 	return 0;
-
-err_irq:
-	clk_disable_unprepare(dev->clk);
 err:
 	return ret;
 }
@@ -1056,8 +1049,6 @@ static int spear_smi_remove(struct platform_device *pdev)
 		WARN_ON(mtd_device_unregister(&flash->mtd));
 	}
 
-	clk_disable_unprepare(dev->clk);
-
 	return 0;
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 02/12] mtd: rawnand: arasan: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  2023-08-21  3:17         ` [PATCH -next v3 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:58           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 03/12] mtd: rawnand: fsmc: " Li Zetao
                           ` (9 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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 "disable_bus_clk" and "disable_controller_clk".

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-3-lizetao1@huawei.com/
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-3-lizetao1@huawei.com/

 drivers/mtd/nand/raw/arasan-nand-controller.c | 29 ++++---------------
 1 file changed, 5 insertions(+), 24 deletions(-)

diff --git a/drivers/mtd/nand/raw/arasan-nand-controller.c b/drivers/mtd/nand/raw/arasan-nand-controller.c
index 906eef70cb6d..4621ec549cc7 100644
--- a/drivers/mtd/nand/raw/arasan-nand-controller.c
+++ b/drivers/mtd/nand/raw/arasan-nand-controller.c
@@ -1440,45 +1440,29 @@ static int anfc_probe(struct platform_device *pdev)
 
 	anfc_reset(nfc);
 
-	nfc->controller_clk = devm_clk_get(&pdev->dev, "controller");
+	nfc->controller_clk = devm_clk_get_enabled(&pdev->dev, "controller");
 	if (IS_ERR(nfc->controller_clk))
 		return PTR_ERR(nfc->controller_clk);
 
-	nfc->bus_clk = devm_clk_get(&pdev->dev, "bus");
+	nfc->bus_clk = devm_clk_get_enabled(&pdev->dev, "bus");
 	if (IS_ERR(nfc->bus_clk))
 		return PTR_ERR(nfc->bus_clk);
 
-	ret = clk_prepare_enable(nfc->controller_clk);
-	if (ret)
-		return ret;
-
-	ret = clk_prepare_enable(nfc->bus_clk);
-	if (ret)
-		goto disable_controller_clk;
-
 	ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
 	if (ret)
-		goto disable_bus_clk;
+		return ret;
 
 	ret = anfc_parse_cs(nfc);
 	if (ret)
-		goto disable_bus_clk;
+		return ret;
 
 	ret = anfc_chips_init(nfc);
 	if (ret)
-		goto disable_bus_clk;
+		return ret;
 
 	platform_set_drvdata(pdev, nfc);
 
 	return 0;
-
-disable_bus_clk:
-	clk_disable_unprepare(nfc->bus_clk);
-
-disable_controller_clk:
-	clk_disable_unprepare(nfc->controller_clk);
-
-	return ret;
 }
 
 static void anfc_remove(struct platform_device *pdev)
@@ -1486,9 +1470,6 @@ static void anfc_remove(struct platform_device *pdev)
 	struct arasan_nfc *nfc = platform_get_drvdata(pdev);
 
 	anfc_chips_cleanup(nfc);
-
-	clk_disable_unprepare(nfc->bus_clk);
-	clk_disable_unprepare(nfc->controller_clk);
 }
 
 static const struct of_device_id anfc_ids[] = {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 03/12] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
  2023-08-21  3:17         ` [PATCH -next v3 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
  2023-08-21  3:17         ` [PATCH -next v3 02/12] mtd: rawnand: arasan: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:58           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 04/12] mtd: rawnand: intel: " Li Zetao
                           ` (8 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-4-lizetao1@huawei.com/
v1 -> v2: Modify commit message and rename the label "disable_clk" to "disable_fsmc"
v1: https://lore.kernel.org/all/20230817024509.3951629-4-lizetao1@huawei.com/

 drivers/mtd/nand/raw/fsmc_nand.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
index 7b4742420dfc..7d587284c9a5 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.
@@ -1111,7 +1107,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 		if (!host->read_dma_chan) {
 			dev_err(&pdev->dev, "Unable to get read dma channel\n");
 			ret = -ENODEV;
-			goto disable_clk;
+			goto disable_fsmc;
 		}
 		host->write_dma_chan = dma_request_channel(mask, filter, NULL);
 		if (!host->write_dma_chan) {
@@ -1155,9 +1151,8 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 release_dma_read_chan:
 	if (host->mode == USE_DMA_ACCESS)
 		dma_release_channel(host->read_dma_chan);
-disable_clk:
+disable_fsmc:
 	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);
 	}
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 04/12] mtd: rawnand: intel: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                           ` (2 preceding siblings ...)
  2023-08-21  3:17         ` [PATCH -next v3 03/12] mtd: rawnand: fsmc: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:58           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 05/12] mtd: rawnand: lpc32xx_slc: " Li Zetao
                           ` (7 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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_disable_unprepare_clk".

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-5-lizetao1@huawei.com/
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-5-lizetao1@huawei.com/

 drivers/mtd/nand/raw/intel-nand-controller.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/nand/raw/intel-nand-controller.c b/drivers/mtd/nand/raw/intel-nand-controller.c
index a9909eb08124..cb5d88f42297 100644
--- a/drivers/mtd/nand/raw/intel-nand-controller.c
+++ b/drivers/mtd/nand/raw/intel-nand-controller.c
@@ -626,16 +626,10 @@ static int ebu_nand_probe(struct platform_device *pdev)
 		goto err_of_node_put;
 	}
 
-	ebu_host->clk = devm_clk_get(dev, NULL);
+	ebu_host->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(ebu_host->clk)) {
 		ret = dev_err_probe(dev, PTR_ERR(ebu_host->clk),
-				    "failed to get clock\n");
-		goto err_of_node_put;
-	}
-
-	ret = clk_prepare_enable(ebu_host->clk);
-	if (ret) {
-		dev_err(dev, "failed to enable clock: %d\n", ret);
+				    "failed to get and enable clock\n");
 		goto err_of_node_put;
 	}
 
@@ -643,7 +637,7 @@ static int ebu_nand_probe(struct platform_device *pdev)
 	if (IS_ERR(ebu_host->dma_tx)) {
 		ret = dev_err_probe(dev, PTR_ERR(ebu_host->dma_tx),
 				    "failed to request DMA tx chan!.\n");
-		goto err_disable_unprepare_clk;
+		goto err_of_node_put;
 	}
 
 	ebu_host->dma_rx = dma_request_chan(dev, "rx");
@@ -698,8 +692,6 @@ static int ebu_nand_probe(struct platform_device *pdev)
 	nand_cleanup(&ebu_host->chip);
 err_cleanup_dma:
 	ebu_dma_cleanup(ebu_host);
-err_disable_unprepare_clk:
-	clk_disable_unprepare(ebu_host->clk);
 err_of_node_put:
 	of_node_put(chip_np);
 
@@ -716,7 +708,6 @@ static void ebu_nand_remove(struct platform_device *pdev)
 	nand_cleanup(&ebu_host->chip);
 	ebu_nand_disable(&ebu_host->chip);
 	ebu_dma_cleanup(ebu_host);
-	clk_disable_unprepare(ebu_host->clk);
 }
 
 static const struct of_device_id ebu_nand_match[] = {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 05/12] mtd: rawnand: lpc32xx_slc: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                           ` (3 preceding siblings ...)
  2023-08-21  3:17         ` [PATCH -next v3 04/12] mtd: rawnand: intel: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:57           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 06/12] mtd: rawnand: mpc5121: " Li Zetao
                           ` (6 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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 "unprepare_clk".

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-6-lizetao1@huawei.com/
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-6-lizetao1@huawei.com/

 drivers/mtd/nand/raw/lpc32xx_slc.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c
index 2201264d3c37..1c5fa855b9f2 100644
--- a/drivers/mtd/nand/raw/lpc32xx_slc.c
+++ b/drivers/mtd/nand/raw/lpc32xx_slc.c
@@ -871,15 +871,12 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 	mtd->dev.parent = &pdev->dev;
 
 	/* Get NAND clock */
-	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, "Clock failure\n");
 		res = -ENOENT;
 		goto enable_wp;
 	}
-	res = clk_prepare_enable(host->clk);
-	if (res)
-		goto enable_wp;
 
 	/* Set NAND IO addresses and command/ready functions */
 	chip->legacy.IO_ADDR_R = SLC_DATA(host->io_base);
@@ -907,13 +904,13 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 				      GFP_KERNEL);
 	if (host->data_buf == NULL) {
 		res = -ENOMEM;
-		goto unprepare_clk;
+		goto enable_wp;
 	}
 
 	res = lpc32xx_nand_dma_setup(host);
 	if (res) {
 		res = -EIO;
-		goto unprepare_clk;
+		goto enable_wp;
 	}
 
 	/* Find NAND device */
@@ -934,8 +931,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 	nand_cleanup(chip);
 release_dma:
 	dma_release_channel(host->dma_chan);
-unprepare_clk:
-	clk_disable_unprepare(host->clk);
 enable_wp:
 	lpc32xx_wp_enable(host);
 
@@ -962,7 +957,6 @@ static void lpc32xx_nand_remove(struct platform_device *pdev)
 	tmp &= ~SLCCFG_CE_LOW;
 	writel(tmp, SLC_CTRL(host->io_base));
 
-	clk_disable_unprepare(host->clk);
 	lpc32xx_wp_enable(host);
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 06/12] mtd: rawnand: mpc5121: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                           ` (4 preceding siblings ...)
  2023-08-21  3:17         ` [PATCH -next v3 05/12] mtd: rawnand: lpc32xx_slc: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:57           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 07/12] mtd: rawnand: mtk: " Li Zetao
                           ` (5 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-7-lizetao1@huawei.com/
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-7-lizetao1@huawei.com/

 drivers/mtd/nand/raw/mpc5121_nfc.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/raw/mpc5121_nfc.c b/drivers/mtd/nand/raw/mpc5121_nfc.c
index 6e8e790f84e7..215610f808f1 100644
--- a/drivers/mtd/nand/raw/mpc5121_nfc.c
+++ b/drivers/mtd/nand/raw/mpc5121_nfc.c
@@ -595,8 +595,6 @@ static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd)
 	struct nand_chip *chip = mtd_to_nand(mtd);
 	struct mpc5121_nfc_prv *prv = nand_get_controller_data(chip);
 
-	clk_disable_unprepare(prv->clk);
-
 	if (prv->csreg)
 		iounmap(prv->csreg);
 }
@@ -717,17 +715,12 @@ static int mpc5121_nfc_probe(struct platform_device *op)
 	}
 
 	/* Enable NFC clock */
-	clk = devm_clk_get(dev, "ipg");
+	clk = devm_clk_get_enabled(dev, "ipg");
 	if (IS_ERR(clk)) {
-		dev_err(dev, "Unable to acquire NFC clock!\n");
+		dev_err(dev, "Unable to acquire and enable NFC clock!\n");
 		retval = PTR_ERR(clk);
 		goto error;
 	}
-	retval = clk_prepare_enable(clk);
-	if (retval) {
-		dev_err(dev, "Unable to enable NFC clock!\n");
-		goto error;
-	}
 	prv->clk = clk;
 
 	/* Reset NAND Flash controller */
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 07/12] mtd: rawnand: mtk: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                           ` (5 preceding siblings ...)
  2023-08-21  3:17         ` [PATCH -next v3 06/12] mtd: rawnand: mpc5121: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:57           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 08/12] mtd: rawnand: stm32_fmc2: " Li Zetao
                           ` (4 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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 "clk_disable". And both mtk_nfc_enable_clk() and
mtk_nfc_disable_clk() now have a single user, which is the resume or
suspend callback, so drop this two helper function and just move related
operations in the resume or suspend function.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Modify the syntax error in the commit message.
v2; https://lore.kernel.org/all/20230818074642.308166-8-lizetao1@huawei.com/
v1 -> v2: Modify commit message and drop two helper functions
mtk_nfc_enable_clk() and mtk_nfc_disable_clk().
v1: https://lore.kernel.org/all/20230817024509.3951629-8-lizetao1@huawei.com/

 drivers/mtd/nand/raw/mtk_nand.c | 62 ++++++++++-----------------------
 1 file changed, 19 insertions(+), 43 deletions(-)

diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c
index b6eb8cb6b5e9..29c8bddde67f 100644
--- a/drivers/mtd/nand/raw/mtk_nand.c
+++ b/drivers/mtd/nand/raw/mtk_nand.c
@@ -1118,32 +1118,6 @@ static irqreturn_t mtk_nfc_irq(int irq, void *id)
 	return IRQ_HANDLED;
 }
 
-static int mtk_nfc_enable_clk(struct device *dev, struct mtk_nfc_clk *clk)
-{
-	int ret;
-
-	ret = clk_prepare_enable(clk->nfi_clk);
-	if (ret) {
-		dev_err(dev, "failed to enable nfi clk\n");
-		return ret;
-	}
-
-	ret = clk_prepare_enable(clk->pad_clk);
-	if (ret) {
-		dev_err(dev, "failed to enable pad clk\n");
-		clk_disable_unprepare(clk->nfi_clk);
-		return ret;
-	}
-
-	return 0;
-}
-
-static void mtk_nfc_disable_clk(struct mtk_nfc_clk *clk)
-{
-	clk_disable_unprepare(clk->nfi_clk);
-	clk_disable_unprepare(clk->pad_clk);
-}
-
 static int mtk_nfc_ooblayout_free(struct mtd_info *mtd, int section,
 				  struct mtd_oob_region *oob_region)
 {
@@ -1545,40 +1519,36 @@ static int mtk_nfc_probe(struct platform_device *pdev)
 		goto release_ecc;
 	}
 
-	nfc->clk.nfi_clk = devm_clk_get(dev, "nfi_clk");
+	nfc->clk.nfi_clk = devm_clk_get_enabled(dev, "nfi_clk");
 	if (IS_ERR(nfc->clk.nfi_clk)) {
 		dev_err(dev, "no clk\n");
 		ret = PTR_ERR(nfc->clk.nfi_clk);
 		goto release_ecc;
 	}
 
-	nfc->clk.pad_clk = devm_clk_get(dev, "pad_clk");
+	nfc->clk.pad_clk = devm_clk_get_enabled(dev, "pad_clk");
 	if (IS_ERR(nfc->clk.pad_clk)) {
 		dev_err(dev, "no pad clk\n");
 		ret = PTR_ERR(nfc->clk.pad_clk);
 		goto release_ecc;
 	}
 
-	ret = mtk_nfc_enable_clk(dev, &nfc->clk);
-	if (ret)
-		goto release_ecc;
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		ret = -EINVAL;
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	ret = devm_request_irq(dev, irq, mtk_nfc_irq, 0x0, "mtk-nand", nfc);
 	if (ret) {
 		dev_err(dev, "failed to request nfi irq\n");
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	ret = dma_set_mask(dev, DMA_BIT_MASK(32));
 	if (ret) {
 		dev_err(dev, "failed to set dma mask\n");
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	platform_set_drvdata(pdev, nfc);
@@ -1586,14 +1556,11 @@ static int mtk_nfc_probe(struct platform_device *pdev)
 	ret = mtk_nfc_nand_chips_init(dev, nfc);
 	if (ret) {
 		dev_err(dev, "failed to init nand chips\n");
-		goto clk_disable;
+		goto release_ecc;
 	}
 
 	return 0;
 
-clk_disable:
-	mtk_nfc_disable_clk(&nfc->clk);
-
 release_ecc:
 	mtk_ecc_release(nfc->ecc);
 
@@ -1618,7 +1585,6 @@ static void mtk_nfc_remove(struct platform_device *pdev)
 	}
 
 	mtk_ecc_release(nfc->ecc);
-	mtk_nfc_disable_clk(&nfc->clk);
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -1626,7 +1592,8 @@ static int mtk_nfc_suspend(struct device *dev)
 {
 	struct mtk_nfc *nfc = dev_get_drvdata(dev);
 
-	mtk_nfc_disable_clk(&nfc->clk);
+	clk_disable_unprepare(nfc->clk.nfi_clk);
+	clk_disable_unprepare(nfc->clk.pad_clk);
 
 	return 0;
 }
@@ -1641,9 +1608,18 @@ static int mtk_nfc_resume(struct device *dev)
 
 	udelay(200);
 
-	ret = mtk_nfc_enable_clk(dev, &nfc->clk);
-	if (ret)
+	ret = clk_prepare_enable(nfc->clk.nfi_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable nfi clk\n");
 		return ret;
+	}
+
+	ret = clk_prepare_enable(nfc->clk.pad_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable pad clk\n");
+		clk_disable_unprepare(nfc->clk.nfi_clk);
+		return ret;
+	}
 
 	/* reset NAND chip if VCC was powered off */
 	list_for_each_entry(chip, &nfc->chips, node) {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 08/12] mtd: rawnand: stm32_fmc2: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                           ` (6 preceding siblings ...)
  2023-08-21  3:17         ` [PATCH -next v3 07/12] mtd: rawnand: mtk: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:57           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 09/12] mtd: rawnand: sunxi: " Li Zetao
                           ` (3 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-9-lizetao1@huawei.com/
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-9-lizetao1@huawei.com/

 drivers/mtd/nand/raw/stm32_fmc2_nand.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
index 2f9e43f64dd7..88811139aaf5 100644
--- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
+++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
@@ -1951,21 +1951,17 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
 
 	init_completion(&nfc->complete);
 
-	nfc->clk = devm_clk_get(nfc->cdev, NULL);
-	if (IS_ERR(nfc->clk))
+	nfc->clk = devm_clk_get_enabled(nfc->cdev, NULL);
+	if (IS_ERR(nfc->clk)) {
+		dev_err(dev, "can not get and enable the clock\n");
 		return PTR_ERR(nfc->clk);
-
-	ret = clk_prepare_enable(nfc->clk);
-	if (ret) {
-		dev_err(dev, "can not enable the clock\n");
-		return ret;
 	}
 
 	rstc = devm_reset_control_get(dev, NULL);
 	if (IS_ERR(rstc)) {
 		ret = PTR_ERR(rstc);
 		if (ret == -EPROBE_DEFER)
-			goto err_clk_disable;
+			return ret;
 	} else {
 		reset_control_assert(rstc);
 		reset_control_deassert(rstc);
@@ -2018,9 +2014,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
 	sg_free_table(&nfc->dma_data_sg);
 	sg_free_table(&nfc->dma_ecc_sg);
 
-err_clk_disable:
-	clk_disable_unprepare(nfc->clk);
-
 	return ret;
 }
 
@@ -2045,8 +2038,6 @@ static void stm32_fmc2_nfc_remove(struct platform_device *pdev)
 	sg_free_table(&nfc->dma_data_sg);
 	sg_free_table(&nfc->dma_ecc_sg);
 
-	clk_disable_unprepare(nfc->clk);
-
 	stm32_fmc2_nfc_wp_enable(nand);
 }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 09/12] mtd: rawnand: sunxi: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                           ` (7 preceding siblings ...)
  2023-08-21  3:17         ` [PATCH -next v3 08/12] mtd: rawnand: stm32_fmc2: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:57           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 10/12] mtd: rawnand: vf610_nfc: " Li Zetao
                           ` (2 subsequent siblings)
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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 "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>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-10-lizetao1@huawei.com/
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-10-lizetao1@huawei.com/

 drivers/mtd/nand/raw/sunxi_nand.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 64c09eae951d..9abf38049d35 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -2094,37 +2094,26 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	nfc->ahb_clk = devm_clk_get(dev, "ahb");
+	nfc->ahb_clk = devm_clk_get_enabled(dev, "ahb");
 	if (IS_ERR(nfc->ahb_clk)) {
 		dev_err(dev, "failed to retrieve ahb clk\n");
 		return PTR_ERR(nfc->ahb_clk);
 	}
 
-	ret = clk_prepare_enable(nfc->ahb_clk);
-	if (ret)
-		return ret;
-
-	nfc->mod_clk = devm_clk_get(dev, "mod");
+	nfc->mod_clk = devm_clk_get_enabled(dev, "mod");
 	if (IS_ERR(nfc->mod_clk)) {
 		dev_err(dev, "failed to retrieve mod clk\n");
-		ret = PTR_ERR(nfc->mod_clk);
-		goto out_ahb_clk_unprepare;
+		return PTR_ERR(nfc->mod_clk);
 	}
 
-	ret = clk_prepare_enable(nfc->mod_clk);
-	if (ret)
-		goto out_ahb_clk_unprepare;
-
 	nfc->reset = devm_reset_control_get_optional_exclusive(dev, "ahb");
-	if (IS_ERR(nfc->reset)) {
-		ret = PTR_ERR(nfc->reset);
-		goto out_mod_clk_unprepare;
-	}
+	if (IS_ERR(nfc->reset))
+		return PTR_ERR(nfc->reset);
 
 	ret = reset_control_deassert(nfc->reset);
 	if (ret) {
 		dev_err(dev, "reset err %d\n", ret);
-		goto out_mod_clk_unprepare;
+		return ret;
 	}
 
 	nfc->caps = of_device_get_match_data(&pdev->dev);
@@ -2163,10 +2152,6 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
 		dma_release_channel(nfc->dmac);
 out_ahb_reset_reassert:
 	reset_control_assert(nfc->reset);
-out_mod_clk_unprepare:
-	clk_disable_unprepare(nfc->mod_clk);
-out_ahb_clk_unprepare:
-	clk_disable_unprepare(nfc->ahb_clk);
 
 	return ret;
 }
@@ -2181,8 +2166,6 @@ static void sunxi_nfc_remove(struct platform_device *pdev)
 
 	if (nfc->dmac)
 		dma_release_channel(nfc->dmac);
-	clk_disable_unprepare(nfc->mod_clk);
-	clk_disable_unprepare(nfc->ahb_clk);
 }
 
 static const struct sunxi_nfc_caps sunxi_nfc_a10_caps = {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 10/12] mtd: rawnand: vf610_nfc: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                           ` (8 preceding siblings ...)
  2023-08-21  3:17         ` [PATCH -next v3 09/12] mtd: rawnand: sunxi: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  3:17         ` [PATCH -next v3 11/12] mtd: spi-nor: nxp-spifi: " Li Zetao
  2023-08-21  3:17         ` [PATCH -next v3 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled() Li Zetao
  11 siblings, 0 replies; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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_disable_clk".

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-11-lizetao1@huawei.com/
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-11-lizetao1@huawei.com/

 drivers/mtd/nand/raw/vf610_nfc.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
index dcdf33dbaef2..1ce9d5c2b1f7 100644
--- a/drivers/mtd/nand/raw/vf610_nfc.c
+++ b/drivers/mtd/nand/raw/vf610_nfc.c
@@ -834,21 +834,15 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 	if (IS_ERR(nfc->regs))
 		return PTR_ERR(nfc->regs);
 
-	nfc->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(nfc->clk))
+	nfc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
+	if (IS_ERR(nfc->clk)) {
+		dev_err(nfc->dev, "Unable to get and enable clock!\n");
 		return PTR_ERR(nfc->clk);
-
-	err = clk_prepare_enable(nfc->clk);
-	if (err) {
-		dev_err(nfc->dev, "Unable to enable clock!\n");
-		return err;
 	}
 
 	of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev);
-	if (!of_id) {
-		err = -ENODEV;
-		goto err_disable_clk;
-	}
+	if (!of_id)
+		return -ENODEV;
 
 	nfc->variant = (enum vf610_nfc_variant)of_id->data;
 
@@ -858,9 +852,8 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 			if (nand_get_flash_node(chip)) {
 				dev_err(nfc->dev,
 					"Only one NAND chip supported!\n");
-				err = -EINVAL;
 				of_node_put(child);
-				goto err_disable_clk;
+				return -EINVAL;
 			}
 
 			nand_set_flash_node(chip, child);
@@ -869,8 +862,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 
 	if (!nand_get_flash_node(chip)) {
 		dev_err(nfc->dev, "NAND chip sub-node missing!\n");
-		err = -ENODEV;
-		goto err_disable_clk;
+		return -ENODEV;
 	}
 
 	chip->options |= NAND_NO_SUBPAGE_WRITE;
@@ -880,7 +872,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 	err = devm_request_irq(nfc->dev, irq, vf610_nfc_irq, 0, DRV_NAME, nfc);
 	if (err) {
 		dev_err(nfc->dev, "Error requesting IRQ!\n");
-		goto err_disable_clk;
+		return err;
 	}
 
 	vf610_nfc_preinit_controller(nfc);
@@ -892,7 +884,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 	/* Scan the NAND chip */
 	err = nand_scan(chip, 1);
 	if (err)
-		goto err_disable_clk;
+		return err;
 
 	platform_set_drvdata(pdev, nfc);
 
@@ -904,8 +896,6 @@ static int vf610_nfc_probe(struct platform_device *pdev)
 
 err_cleanup_nand:
 	nand_cleanup(chip);
-err_disable_clk:
-	clk_disable_unprepare(nfc->clk);
 	return err;
 }
 
@@ -918,7 +908,6 @@ static void vf610_nfc_remove(struct platform_device *pdev)
 	ret = mtd_device_unregister(nand_to_mtd(chip));
 	WARN_ON(ret);
 	nand_cleanup(chip);
-	clk_disable_unprepare(nfc->clk);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 11/12] mtd: spi-nor: nxp-spifi: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                           ` (9 preceding siblings ...)
  2023-08-21  3:17         ` [PATCH -next v3 10/12] mtd: rawnand: vf610_nfc: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:38           ` Miquel Raynal
  2023-08-21  3:17         ` [PATCH -next v3 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled() Li Zetao
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

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 "dis_clks" and "dis_clk_reg".

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-12-lizetao1@huawei.com/
v1 -> v2: Modify commit message.
v1: https://lore.kernel.org/all/20230817024509.3951629-12-lizetao1@huawei.com/

 drivers/mtd/spi-nor/controllers/nxp-spifi.c | 33 ++++-----------------
 1 file changed, 6 insertions(+), 27 deletions(-)

diff --git a/drivers/mtd/spi-nor/controllers/nxp-spifi.c b/drivers/mtd/spi-nor/controllers/nxp-spifi.c
index 337e83bf3362..5d8f47ab146f 100644
--- a/drivers/mtd/spi-nor/controllers/nxp-spifi.c
+++ b/drivers/mtd/spi-nor/controllers/nxp-spifi.c
@@ -394,30 +394,18 @@ static int nxp_spifi_probe(struct platform_device *pdev)
 	if (IS_ERR(spifi->flash_base))
 		return PTR_ERR(spifi->flash_base);
 
-	spifi->clk_spifi = devm_clk_get(&pdev->dev, "spifi");
+	spifi->clk_spifi = devm_clk_get_enabled(&pdev->dev, "spifi");
 	if (IS_ERR(spifi->clk_spifi)) {
-		dev_err(&pdev->dev, "spifi clock not found\n");
+		dev_err(&pdev->dev, "spifi clock not found or unable to enable\n");
 		return PTR_ERR(spifi->clk_spifi);
 	}
 
-	spifi->clk_reg = devm_clk_get(&pdev->dev, "reg");
+	spifi->clk_reg = devm_clk_get_enabled(&pdev->dev, "reg");
 	if (IS_ERR(spifi->clk_reg)) {
-		dev_err(&pdev->dev, "reg clock not found\n");
+		dev_err(&pdev->dev, "reg clock not found or unable to enable\n");
 		return PTR_ERR(spifi->clk_reg);
 	}
 
-	ret = clk_prepare_enable(spifi->clk_reg);
-	if (ret) {
-		dev_err(&pdev->dev, "unable to enable reg clock\n");
-		return ret;
-	}
-
-	ret = clk_prepare_enable(spifi->clk_spifi);
-	if (ret) {
-		dev_err(&pdev->dev, "unable to enable spifi clock\n");
-		goto dis_clk_reg;
-	}
-
 	spifi->dev = &pdev->dev;
 	platform_set_drvdata(pdev, spifi);
 
@@ -430,24 +418,17 @@ static int nxp_spifi_probe(struct platform_device *pdev)
 	flash_np = of_get_next_available_child(pdev->dev.of_node, NULL);
 	if (!flash_np) {
 		dev_err(&pdev->dev, "no SPI flash device to configure\n");
-		ret = -ENODEV;
-		goto dis_clks;
+		return -ENODEV;
 	}
 
 	ret = nxp_spifi_setup_flash(spifi, flash_np);
 	of_node_put(flash_np);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to setup flash chip\n");
-		goto dis_clks;
+		return ret;
 	}
 
 	return 0;
-
-dis_clks:
-	clk_disable_unprepare(spifi->clk_spifi);
-dis_clk_reg:
-	clk_disable_unprepare(spifi->clk_reg);
-	return ret;
 }
 
 static int nxp_spifi_remove(struct platform_device *pdev)
@@ -455,8 +436,6 @@ static int nxp_spifi_remove(struct platform_device *pdev)
 	struct nxp_spifi *spifi = platform_get_drvdata(pdev);
 
 	mtd_device_unregister(&spifi->nor.mtd);
-	clk_disable_unprepare(spifi->clk_spifi);
-	clk_disable_unprepare(spifi->clk_reg);
 
 	return 0;
 }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH -next v3 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled()
  2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
                           ` (10 preceding siblings ...)
  2023-08-21  3:17         ` [PATCH -next v3 11/12] mtd: spi-nor: nxp-spifi: " Li Zetao
@ 2023-08-21  3:17         ` Li Zetao
  2023-08-21  7:57           ` Miquel Raynal
  11 siblings, 1 reply; 58+ messages in thread
From: Li Zetao @ 2023-08-21  3:17 UTC (permalink / raw)
  To: miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi, lizetao1,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
and enabled clocks"), devm_clk_get_optional() and clk_prepare_enable() can
now be replaced by devm_clk_get_optional_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 "no_dev".

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Modify the syntax error in the commit message.
v2: https://lore.kernel.org/all/20230818074642.308166-13-lizetao1@huawei.com/
v1 -> v2: This is a new patch.

 drivers/mtd/nand/raw/orion_nand.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/mtd/nand/raw/orion_nand.c b/drivers/mtd/nand/raw/orion_nand.c
index 7e0313889b50..2951d81614fd 100644
--- a/drivers/mtd/nand/raw/orion_nand.c
+++ b/drivers/mtd/nand/raw/orion_nand.c
@@ -169,16 +169,10 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, info);
 
 	/* Not all platforms can gate the clock, so it is optional. */
-	info->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	info->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
 	if (IS_ERR(info->clk))
 		return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
-				     "failed to get clock!\n");
-
-	ret = clk_prepare_enable(info->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to prepare clock!\n");
-		return ret;
-	}
+				     "failed to get and enable clock!\n");
 
 	/*
 	 * This driver assumes that the default ECC engine should be TYPE_SOFT.
@@ -189,19 +183,13 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 
 	ret = nand_scan(nc, 1);
 	if (ret)
-		goto no_dev;
+		return ret;
 
 	mtd->name = "orion_nand";
 	ret = mtd_device_register(mtd, board->parts, board->nr_parts);
-	if (ret) {
+	if (ret)
 		nand_cleanup(nc);
-		goto no_dev;
-	}
-
-	return 0;
 
-no_dev:
-	clk_disable_unprepare(info->clk);
 	return ret;
 }
 
@@ -215,8 +203,6 @@ static void orion_nand_remove(struct platform_device *pdev)
 	WARN_ON(ret);
 
 	nand_cleanup(chip);
-
-	clk_disable_unprepare(info->clk);
 }
 
 #ifdef CONFIG_OF
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 11/12] mtd: spi-nor: nxp-spifi: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 11/12] mtd: spi-nor: nxp-spifi: " Li Zetao
@ 2023-08-21  7:38           ` Miquel Raynal
  2023-08-21  7:54             ` Miquel Raynal
  0 siblings, 1 reply; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:38 UTC (permalink / raw)
  To: Li Zetao
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

Hi Tudor,

lizetao1@huawei.com wrote on Mon, 21 Aug 2023 11:17:36 +0800:

> 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 "dis_clks" and "dis_clk_reg".

This patch seems very simple, do you mind if I apply it directly into
mtd/next for the next PR?

Thanks,
Miquèl

> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---
> v2 -> v3: Modify the syntax error in the commit message.
> v2: https://lore.kernel.org/all/20230818074642.308166-12-lizetao1@huawei.com/
> v1 -> v2: Modify commit message.
> v1: https://lore.kernel.org/all/20230817024509.3951629-12-lizetao1@huawei.com/
> 
>  drivers/mtd/spi-nor/controllers/nxp-spifi.c | 33 ++++-----------------
>  1 file changed, 6 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/controllers/nxp-spifi.c b/drivers/mtd/spi-nor/controllers/nxp-spifi.c
> index 337e83bf3362..5d8f47ab146f 100644
> --- a/drivers/mtd/spi-nor/controllers/nxp-spifi.c
> +++ b/drivers/mtd/spi-nor/controllers/nxp-spifi.c
> @@ -394,30 +394,18 @@ static int nxp_spifi_probe(struct platform_device *pdev)
>  	if (IS_ERR(spifi->flash_base))
>  		return PTR_ERR(spifi->flash_base);
>  
> -	spifi->clk_spifi = devm_clk_get(&pdev->dev, "spifi");
> +	spifi->clk_spifi = devm_clk_get_enabled(&pdev->dev, "spifi");
>  	if (IS_ERR(spifi->clk_spifi)) {
> -		dev_err(&pdev->dev, "spifi clock not found\n");
> +		dev_err(&pdev->dev, "spifi clock not found or unable to enable\n");
>  		return PTR_ERR(spifi->clk_spifi);
>  	}
>  
> -	spifi->clk_reg = devm_clk_get(&pdev->dev, "reg");
> +	spifi->clk_reg = devm_clk_get_enabled(&pdev->dev, "reg");
>  	if (IS_ERR(spifi->clk_reg)) {
> -		dev_err(&pdev->dev, "reg clock not found\n");
> +		dev_err(&pdev->dev, "reg clock not found or unable to enable\n");
>  		return PTR_ERR(spifi->clk_reg);
>  	}
>  
> -	ret = clk_prepare_enable(spifi->clk_reg);
> -	if (ret) {
> -		dev_err(&pdev->dev, "unable to enable reg clock\n");
> -		return ret;
> -	}
> -
> -	ret = clk_prepare_enable(spifi->clk_spifi);
> -	if (ret) {
> -		dev_err(&pdev->dev, "unable to enable spifi clock\n");
> -		goto dis_clk_reg;
> -	}
> -
>  	spifi->dev = &pdev->dev;
>  	platform_set_drvdata(pdev, spifi);
>  
> @@ -430,24 +418,17 @@ static int nxp_spifi_probe(struct platform_device *pdev)
>  	flash_np = of_get_next_available_child(pdev->dev.of_node, NULL);
>  	if (!flash_np) {
>  		dev_err(&pdev->dev, "no SPI flash device to configure\n");
> -		ret = -ENODEV;
> -		goto dis_clks;
> +		return -ENODEV;
>  	}
>  
>  	ret = nxp_spifi_setup_flash(spifi, flash_np);
>  	of_node_put(flash_np);
>  	if (ret) {
>  		dev_err(&pdev->dev, "unable to setup flash chip\n");
> -		goto dis_clks;
> +		return ret;
>  	}
>  
>  	return 0;
> -
> -dis_clks:
> -	clk_disable_unprepare(spifi->clk_spifi);
> -dis_clk_reg:
> -	clk_disable_unprepare(spifi->clk_reg);
> -	return ret;
>  }
>  
>  static int nxp_spifi_remove(struct platform_device *pdev)
> @@ -455,8 +436,6 @@ static int nxp_spifi_remove(struct platform_device *pdev)
>  	struct nxp_spifi *spifi = platform_get_drvdata(pdev);
>  
>  	mtd_device_unregister(&spifi->nor.mtd);
> -	clk_disable_unprepare(spifi->clk_spifi);
> -	clk_disable_unprepare(spifi->clk_reg);
>  
>  	return 0;
>  }



^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 11/12] mtd: spi-nor: nxp-spifi: Use helper function devm_clk_get_enabled()
  2023-08-21  7:38           ` Miquel Raynal
@ 2023-08-21  7:54             ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:54 UTC (permalink / raw)
  To: Li Zetao
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

Hi again,

miquel.raynal@bootlin.com wrote on Mon, 21 Aug 2023 09:38:25 +0200:

> Hi Tudor,
> 
> lizetao1@huawei.com wrote on Mon, 21 Aug 2023 11:17:36 +0800:
> 
> > 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 "dis_clks" and "dis_clk_reg".  
> 
> This patch seems very simple, do you mind if I apply it directly into
> mtd/next for the next PR?

I see you already took that one, perfect ;-) Sorry for the noise.

Thanks,
Miquèl


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
@ 2023-08-21  7:57           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:57 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:26 UTC, Li Zetao wrote:
> 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_irq".
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled() Li Zetao
@ 2023-08-21  7:57           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:57 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:37 UTC, Li Zetao wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
> and enabled clocks"), devm_clk_get_optional() and clk_prepare_enable() can
> now be replaced by devm_clk_get_optional_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 "no_dev".
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 09/12] mtd: rawnand: sunxi: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 09/12] mtd: rawnand: sunxi: " Li Zetao
@ 2023-08-21  7:57           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:57 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:34 UTC, Li Zetao wrote:
> 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 "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>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 08/12] mtd: rawnand: stm32_fmc2: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 08/12] mtd: rawnand: stm32_fmc2: " Li Zetao
@ 2023-08-21  7:57           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:57 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:33 UTC, Li Zetao wrote:
> 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>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 07/12] mtd: rawnand: mtk: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 07/12] mtd: rawnand: mtk: " Li Zetao
@ 2023-08-21  7:57           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:57 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:32 UTC, Li Zetao wrote:
> 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 "clk_disable". And both mtk_nfc_enable_clk() and
> mtk_nfc_disable_clk() now have a single user, which is the resume or
> suspend callback, so drop this two helper function and just move related
> operations in the resume or suspend function.
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 06/12] mtd: rawnand: mpc5121: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 06/12] mtd: rawnand: mpc5121: " Li Zetao
@ 2023-08-21  7:57           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:57 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:31 UTC, Li Zetao wrote:
> 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.
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 05/12] mtd: rawnand: lpc32xx_slc: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 05/12] mtd: rawnand: lpc32xx_slc: " Li Zetao
@ 2023-08-21  7:57           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:57 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:30 UTC, Li Zetao wrote:
> 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 "unprepare_clk".
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 04/12] mtd: rawnand: intel: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 04/12] mtd: rawnand: intel: " Li Zetao
@ 2023-08-21  7:58           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:58 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:29 UTC, Li Zetao wrote:
> 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_disable_unprepare_clk".
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 03/12] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 03/12] mtd: rawnand: fsmc: " Li Zetao
@ 2023-08-21  7:58           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:58 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:28 UTC, Li Zetao wrote:
> 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>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH -next v3 02/12] mtd: rawnand: arasan: Use helper function devm_clk_get_enabled()
  2023-08-21  3:17         ` [PATCH -next v3 02/12] mtd: rawnand: arasan: " Li Zetao
@ 2023-08-21  7:58           ` Miquel Raynal
  0 siblings, 0 replies; 58+ messages in thread
From: Miquel Raynal @ 2023-08-21  7:58 UTC (permalink / raw)
  To: Li Zetao, miquel.raynal
  Cc: alexandre.torgue, angelogioacchino.delregno, christophe.kerello,
	christophe.leroy, dmitry.torokhov, frank.li, geert+renesas,
	heiko, jernej.skrabec, jinpu.wang, linux-arm-kernel,
	linux-mediatek, linux-mtd, linux-stm32, linux-sunxi,
	martin.blumenstingl, matthias.bgg, mcoquelin.stm32, michael,
	michal.simek, paul, philmd, pratyush, richard, robh, rogerq,
	samuel, stefan, tudor.ambarus, u.kleine-koenig, vigneshr, vz,
	wens, yangyingliang

On Mon, 2023-08-21 at 03:17:27 UTC, Li Zetao wrote:
> 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 "disable_bus_clk" and "disable_controller_clk".
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel


^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2023-08-21  7:59 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-17  2:44 [PATCH -next 00/11] mtd: Use devm_clk_get_enabled() to simplify the drivers Li Zetao
2023-08-17  2:44 ` [PATCH -next 01/11] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
2023-08-17  2:45 ` [PATCH -next 02/11] mtd: rawnand: arasan: " Li Zetao
2023-08-17  2:45 ` [PATCH -next 03/11] mtd: rawnand: fsmc: " Li Zetao
2023-08-17  8:31   ` Miquel Raynal
2023-08-17  2:45 ` [PATCH -next 04/11] mtd: rawnand: intel: " Li Zetao
2023-08-17  2:45 ` [PATCH -next 05/11] mtd: rawnand: lpc32xx_slc: " Li Zetao
2023-08-17  2:45 ` [PATCH -next 06/11] mtd: rawnand: mpc5121: " Li Zetao
2023-08-17  2:45 ` [PATCH -next 07/11] mtd: rawnand: mtk: " Li Zetao
2023-08-17  8:34   ` Miquel Raynal
2023-08-17  2:45 ` [PATCH -next 08/11] mtd: rawnand: stm32_fmc2: " Li Zetao
2023-08-17  2:45 ` [PATCH -next 09/11] mtd: rawnand: sunxi: " Li Zetao
2023-08-17  2:45 ` [PATCH -next 10/11] mtd: rawnand: vf610_nfc: " Li Zetao
2023-08-17  2:45 ` [PATCH -next 11/11] mtd: spi-nor: " Li Zetao
2023-08-17  8:37   ` Miquel Raynal
2023-08-18  7:46 ` [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
2023-08-18  7:46   ` [PATCH -next v2 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
2023-08-18  7:46   ` [PATCH -next v2 02/12] mtd: rawnand: arasan: " Li Zetao
2023-08-18  8:10     ` Miquel Raynal
2023-08-18  8:12       ` Miquel Raynal
2023-08-21  3:17       ` [PATCH -next v3 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Li Zetao
2023-08-21  3:17         ` [PATCH -next v3 01/12] mtd: spear_smi: Use helper function devm_clk_get_enabled() Li Zetao
2023-08-21  7:57           ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 02/12] mtd: rawnand: arasan: " Li Zetao
2023-08-21  7:58           ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 03/12] mtd: rawnand: fsmc: " Li Zetao
2023-08-21  7:58           ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 04/12] mtd: rawnand: intel: " Li Zetao
2023-08-21  7:58           ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 05/12] mtd: rawnand: lpc32xx_slc: " Li Zetao
2023-08-21  7:57           ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 06/12] mtd: rawnand: mpc5121: " Li Zetao
2023-08-21  7:57           ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 07/12] mtd: rawnand: mtk: " Li Zetao
2023-08-21  7:57           ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 08/12] mtd: rawnand: stm32_fmc2: " Li Zetao
2023-08-21  7:57           ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 09/12] mtd: rawnand: sunxi: " Li Zetao
2023-08-21  7:57           ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 10/12] mtd: rawnand: vf610_nfc: " Li Zetao
2023-08-21  3:17         ` [PATCH -next v3 11/12] mtd: spi-nor: nxp-spifi: " Li Zetao
2023-08-21  7:38           ` Miquel Raynal
2023-08-21  7:54             ` Miquel Raynal
2023-08-21  3:17         ` [PATCH -next v3 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled() Li Zetao
2023-08-21  7:57           ` Miquel Raynal
2023-08-18  7:46   ` [PATCH -next v2 03/12] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled() Li Zetao
2023-08-18  8:11     ` Miquel Raynal
2023-08-18  7:46   ` [PATCH -next v2 04/12] mtd: rawnand: intel: " Li Zetao
2023-08-18  7:46   ` [PATCH -next v2 05/12] mtd: rawnand: lpc32xx_slc: " Li Zetao
2023-08-18  7:46   ` [PATCH -next v2 06/12] mtd: rawnand: mpc5121: " Li Zetao
2023-08-18  7:46   ` [PATCH -next v2 07/12] mtd: rawnand: mtk: " Li Zetao
2023-08-18  7:46   ` [PATCH -next v2 08/12] mtd: rawnand: stm32_fmc2: " Li Zetao
2023-08-18  7:46   ` [PATCH -next v2 09/12] mtd: rawnand: sunxi: " Li Zetao
2023-08-18  7:46   ` [PATCH -next v2 10/12] mtd: rawnand: vf610_nfc: " Li Zetao
2023-08-18  7:46   ` [PATCH -next v2 11/12] mtd: spi-nor: nxp-spifi: " Li Zetao
2023-08-18 10:19     ` Tudor Ambarus
2023-08-18  7:46   ` [PATCH -next v2 12/12] mtd: rawnand: orion: Use helper function devm_clk_get_optional_enabled() Li Zetao
2023-08-18 10:28   ` (subset) [PATCH -next v2 00/12] mtd: Use devm_clk_get_*() helper function to simplify the drivers Tudor Ambarus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).