From: gmbnomis@gmail.com (Simon Baatz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/2] mtd: nand: orion: improve handling of optional clock
Date: Mon, 27 Mar 2017 20:02:08 +0200 [thread overview]
Message-ID: <20170327180208.13414-2-gmbnomis@gmail.com> (raw)
In-Reply-To: <20170327180208.13414-1-gmbnomis@gmail.com>
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@gmail.com>
---
Changes in v2:
* added patch
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 3acdc20485f1..f8e463a97b9e 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;
}
--
2.9.3
next prev parent reply other threads:[~2017-03-27 18:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-27 18:02 [PATCH v2 1/2] mtd: nand: orion: fix clk handling Simon Baatz
2017-03-27 18:02 ` Simon Baatz [this message]
2017-03-27 18:19 ` Uwe Kleine-König
2017-03-29 19:36 ` Simon Baatz
2017-03-29 19:39 ` Uwe Kleine-König
2017-03-29 19:40 ` Boris Brezillon
2017-03-29 20:03 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170327180208.13414-2-gmbnomis@gmail.com \
--to=gmbnomis@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).