Skip to content

Commit 4195b64

Browse files
Li Zetaomiquelraynal
authored andcommitted
mtd: rawnand: vf610_nfc: Use helper function devm_clk_get_enabled()
Since commit 7ef9651 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables (and possibly prepares) the clocks for the whole lifetime of the device. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly, so drop the label "err_disable_clk". Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Li Zetao <lizetao1@huawei.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent a95da27 commit 4195b64

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

drivers/mtd/nand/raw/vf610_nfc.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -834,21 +834,15 @@ static int vf610_nfc_probe(struct platform_device *pdev)
834834
if (IS_ERR(nfc->regs))
835835
return PTR_ERR(nfc->regs);
836836

837-
nfc->clk = devm_clk_get(&pdev->dev, NULL);
838-
if (IS_ERR(nfc->clk))
837+
nfc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
838+
if (IS_ERR(nfc->clk)) {
839+
dev_err(nfc->dev, "Unable to get and enable clock!\n");
839840
return PTR_ERR(nfc->clk);
840-
841-
err = clk_prepare_enable(nfc->clk);
842-
if (err) {
843-
dev_err(nfc->dev, "Unable to enable clock!\n");
844-
return err;
845841
}
846842

847843
of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev);
848-
if (!of_id) {
849-
err = -ENODEV;
850-
goto err_disable_clk;
851-
}
844+
if (!of_id)
845+
return -ENODEV;
852846

853847
nfc->variant = (uintptr_t)of_id->data;
854848

@@ -858,9 +852,8 @@ static int vf610_nfc_probe(struct platform_device *pdev)
858852
if (nand_get_flash_node(chip)) {
859853
dev_err(nfc->dev,
860854
"Only one NAND chip supported!\n");
861-
err = -EINVAL;
862855
of_node_put(child);
863-
goto err_disable_clk;
856+
return -EINVAL;
864857
}
865858

866859
nand_set_flash_node(chip, child);
@@ -869,8 +862,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
869862

870863
if (!nand_get_flash_node(chip)) {
871864
dev_err(nfc->dev, "NAND chip sub-node missing!\n");
872-
err = -ENODEV;
873-
goto err_disable_clk;
865+
return -ENODEV;
874866
}
875867

876868
chip->options |= NAND_NO_SUBPAGE_WRITE;
@@ -880,7 +872,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
880872
err = devm_request_irq(nfc->dev, irq, vf610_nfc_irq, 0, DRV_NAME, nfc);
881873
if (err) {
882874
dev_err(nfc->dev, "Error requesting IRQ!\n");
883-
goto err_disable_clk;
875+
return err;
884876
}
885877

886878
vf610_nfc_preinit_controller(nfc);
@@ -892,7 +884,7 @@ static int vf610_nfc_probe(struct platform_device *pdev)
892884
/* Scan the NAND chip */
893885
err = nand_scan(chip, 1);
894886
if (err)
895-
goto err_disable_clk;
887+
return err;
896888

897889
platform_set_drvdata(pdev, nfc);
898890

@@ -904,8 +896,6 @@ static int vf610_nfc_probe(struct platform_device *pdev)
904896

905897
err_cleanup_nand:
906898
nand_cleanup(chip);
907-
err_disable_clk:
908-
clk_disable_unprepare(nfc->clk);
909899
return err;
910900
}
911901

@@ -918,7 +908,6 @@ static void vf610_nfc_remove(struct platform_device *pdev)
918908
ret = mtd_device_unregister(nand_to_mtd(chip));
919909
WARN_ON(ret);
920910
nand_cleanup(chip);
921-
clk_disable_unprepare(nfc->clk);
922911
}
923912

924913
#ifdef CONFIG_PM_SLEEP

0 commit comments

Comments
 (0)