Commit ef980cf8 authored by Simon Baatz's avatar Simon Baatz Committed by Boris Brezillon

mtd: nand: orion: improve handling of optional clock

The clock gate used by orion_nand is not available on all platforms.
When getting this optional clock gate, the code masked all errors.
Let's be more precise here and actually only allow ENOENT.

EPROBE_DEFER is handled like any other error code since probe deferral
is not supported by drivers using module_platform_driver_probe().
Signed-off-by: default avatarSimon Baatz <gmbnomis@gmail.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 675b11d9
...@@ -156,8 +156,17 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -156,8 +156,17 @@ static int __init orion_nand_probe(struct platform_device *pdev)
/* Not all platforms can gate the clock, so it is not /* Not all platforms can gate the clock, so it is not
an error if the clock does not exists. */ an error if the clock does not exists. */
info->clk = devm_clk_get(&pdev->dev, NULL); info->clk = devm_clk_get(&pdev->dev, NULL);
if (!IS_ERR(info->clk)) if (IS_ERR(info->clk)) {
clk_prepare_enable(info->clk); ret = PTR_ERR(info->clk);
if (ret == -ENOENT) {
info->clk = NULL;
} else {
dev_err(&pdev->dev, "failed to get clock!\n");
return ret;
}
}
clk_prepare_enable(info->clk);
ret = nand_scan(mtd, 1); ret = nand_scan(mtd, 1);
if (ret) if (ret)
...@@ -173,9 +182,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) ...@@ -173,9 +182,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
return 0; return 0;
no_dev: no_dev:
if (!IS_ERR(info->clk)) clk_disable_unprepare(info->clk);
clk_disable_unprepare(info->clk);
return ret; return ret;
} }
...@@ -187,8 +194,7 @@ static int orion_nand_remove(struct platform_device *pdev) ...@@ -187,8 +194,7 @@ static int orion_nand_remove(struct platform_device *pdev)
nand_release(mtd); nand_release(mtd);
if (!IS_ERR(info->clk)) clk_disable_unprepare(info->clk);
clk_disable_unprepare(info->clk);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment