mtd: nand: orion: improve handling of optional clock

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed May 10 19:59:11 PDT 2017


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=ef980cf8b05bc862f4533fcdeae2911e6ff7027a
Commit:     ef980cf8b05bc862f4533fcdeae2911e6ff7027a
Parent:     675b11d94ce9baa5eb365a51b35d2793f77c8ab8
Author:     Simon Baatz <gmbnomis at gmail.com>
AuthorDate: Mon Mar 27 20:02:08 2017 +0200
Committer:  Boris Brezillon <boris.brezillon at free-electrons.com>
CommitDate: Wed Mar 29 17:05:37 2017 +0200

    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: Simon Baatz <gmbnomis at gmail.com>
    Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
 drivers/mtd/nand/orion_nand.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 3acdc20..f8e463a 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -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
 	   an error if the clock does not exists. */
 	info->clk = devm_clk_get(&pdev->dev, NULL);
-	if (!IS_ERR(info->clk))
-		clk_prepare_enable(info->clk);
+	if (IS_ERR(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);
 	if (ret)
@@ -173,9 +182,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 	return 0;
 
 no_dev:
-	if (!IS_ERR(info->clk))
-		clk_disable_unprepare(info->clk);
-
+	clk_disable_unprepare(info->clk);
 	return ret;
 }
 
@@ -187,8 +194,7 @@ static int orion_nand_remove(struct platform_device *pdev)
 
 	nand_release(mtd);
 
-	if (!IS_ERR(info->clk))
-		clk_disable_unprepare(info->clk);
+	clk_disable_unprepare(info->clk);
 
 	return 0;
 }



More information about the linux-mtd-cvs mailing list