mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-26 08:51:13 +00:00
ramips: mt7621_nand: use clk_get_optional_enabled
Simplifies the code by removing clk_disable_unprepare. Also removed gotos and used dev_err_probe. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://github.com/openwrt/openwrt/pull/16133 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
parent
9f8599aebe
commit
11403697c9
@ -1290,44 +1290,28 @@ static int mt7621_nfc_probe(struct platform_device *pdev)
|
|||||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nfi");
|
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nfi");
|
||||||
nfc->nfi_base = res->start;
|
nfc->nfi_base = res->start;
|
||||||
nfc->nfi_regs = devm_ioremap_resource(dev, res);
|
nfc->nfi_regs = devm_ioremap_resource(dev, res);
|
||||||
if (IS_ERR(nfc->nfi_regs)) {
|
if (IS_ERR(nfc->nfi_regs))
|
||||||
ret = PTR_ERR(nfc->nfi_regs);
|
return PTR_ERR(nfc->nfi_regs);
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ecc");
|
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ecc");
|
||||||
nfc->ecc_regs = devm_ioremap_resource(dev, res);
|
nfc->ecc_regs = devm_ioremap_resource(dev, res);
|
||||||
if (IS_ERR(nfc->ecc_regs)) {
|
if (IS_ERR(nfc->ecc_regs))
|
||||||
ret = PTR_ERR(nfc->ecc_regs);
|
return PTR_ERR(nfc->ecc_regs);
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
nfc->nfi_clk = devm_clk_get(dev, "nfi_clk");
|
nfc->nfi_clk = devm_clk_get_optional_enabled(dev, "nfi_clk");
|
||||||
if (IS_ERR(nfc->nfi_clk)) {
|
if (IS_ERR(nfc->nfi_clk))
|
||||||
|
return PTR_ERR(nfc->nfi_clk);
|
||||||
|
|
||||||
|
if (!nfc->nfi_clk)
|
||||||
dev_warn(dev, "nfi clk not provided\n");
|
dev_warn(dev, "nfi clk not provided\n");
|
||||||
nfc->nfi_clk = NULL;
|
|
||||||
} else {
|
|
||||||
ret = clk_prepare_enable(nfc->nfi_clk);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(dev, "Failed to enable nfi core clock\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
platform_set_drvdata(pdev, nfc);
|
platform_set_drvdata(pdev, nfc);
|
||||||
|
|
||||||
ret = mt7621_nfc_init_chip(nfc);
|
ret = mt7621_nfc_init_chip(nfc);
|
||||||
if (ret) {
|
if (ret)
|
||||||
dev_err(dev, "Failed to initialize nand chip\n");
|
return dev_err_probe(dev, ret, "Failed to initialize nand chip\n");
|
||||||
goto clk_disable;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
clk_disable:
|
|
||||||
clk_disable_unprepare(nfc->nfi_clk);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mt7621_nfc_remove(struct platform_device *pdev)
|
static int mt7621_nfc_remove(struct platform_device *pdev)
|
||||||
@ -1339,7 +1323,6 @@ static int mt7621_nfc_remove(struct platform_device *pdev)
|
|||||||
mtk_bmt_detach(mtd);
|
mtk_bmt_detach(mtd);
|
||||||
mtd_device_unregister(mtd);
|
mtd_device_unregister(mtd);
|
||||||
nand_cleanup(nand);
|
nand_cleanup(nand);
|
||||||
clk_disable_unprepare(nfc->nfi_clk);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user