LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Gilad Ben-Yossef <gilad@benyossef.com>
To: Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Cc: Ofir Drang <ofir.drang@arm.com>,
	linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-crypto@vger.kernel.org
Subject: [PATCH v2 2/5] crypto: ccree: better clock handling
Date: Thu, 24 May 2018 15:19:07 +0100	[thread overview]
Message-ID: <1527171551-21979-3-git-send-email-gilad@benyossef.com> (raw)
In-Reply-To: <1527171551-21979-1-git-send-email-gilad@benyossef.com>

Use managed clock handling, differentiate between no clock (possibly OK)
and clock init failure (never OK) and correctly handle clock detection
being deferred.

Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 drivers/crypto/ccree/cc_driver.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index 6f93ce7..b266657 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -190,6 +190,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	u64 dma_mask;
 	const struct cc_hw_data *hw_rev;
 	const struct of_device_id *dev_id;
+	struct clk *clk;
 	int rc = 0;
 
 	new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL);
@@ -219,7 +220,24 @@ static int init_cc_resources(struct platform_device *plat_dev)
 	platform_set_drvdata(plat_dev, new_drvdata);
 	new_drvdata->plat_dev = plat_dev;
 
-	new_drvdata->clk = of_clk_get(np, 0);
+	clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(clk))
+		switch (PTR_ERR(clk)) {
+		/* Clock is optional so this might be fine */
+		case -ENOENT:
+			break;
+
+		/* Clock not available, let's try again soon */
+		case -EPROBE_DEFER:
+			return -EPROBE_DEFER;
+
+		default:
+			dev_err(dev, "Error getting clock: %ld\n",
+				PTR_ERR(clk));
+			return PTR_ERR(clk);
+		}
+	new_drvdata->clk = clk;
+
 	new_drvdata->coherent = of_dma_is_coherent(np);
 
 	/* Get device resources */
-- 
2.7.4

  parent reply	other threads:[~2018-05-24 14:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 14:19 [PATCH v2 0/5] crypto: ccree: cleanup, fixes and R-Car enabling Gilad Ben-Yossef
2018-05-24 14:19 ` [PATCH v2 1/5] crypto: ccree: correct host regs offset Gilad Ben-Yossef
2018-05-29 16:12   ` Simon Horman
2018-05-31 11:51     ` Gilad Ben-Yossef
2018-05-24 14:19 ` Gilad Ben-Yossef [this message]
2018-05-29 16:13   ` [PATCH v2 2/5] crypto: ccree: better clock handling Simon Horman
2018-05-24 14:19 ` [PATCH v2 3/5] crypto: ccree: silence debug prints Gilad Ben-Yossef
2018-05-29 16:13   ` Simon Horman
2018-05-24 14:19 ` [PATCH v2 4/5] clk: renesas: r8a7795: add ccree clock bindings Gilad Ben-Yossef
2018-05-29  8:48   ` Geert Uytterhoeven
2018-05-24 14:19 ` [PATCH v2 5/5] arm64: dts: renesas: r8a7795: add ccree binding Gilad Ben-Yossef
2018-05-29 16:19   ` Simon Horman
2018-05-31 11:55     ` Gilad Ben-Yossef
2018-06-01  8:12       ` Geert Uytterhoeven
2018-06-02 13:12         ` Simon Horman
2018-06-01  8:07   ` Geert Uytterhoeven
2018-05-30 16:28 ` [PATCH v2 0/5] crypto: ccree: cleanup, fixes and R-Car enabling Herbert Xu
2018-06-19 12:58 ` Geert Uytterhoeven
2018-06-19 13:57   ` Gilad Ben-Yossef
2018-06-20  8:51     ` Simon Horman
2018-06-21  5:00       ` Gilad Ben-Yossef

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=1527171551-21979-3-git-send-email-gilad@benyossef.com \
    --to=gilad@benyossef.com \
    --cc=catalin.marinas@arm.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@verge.net.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=ofir.drang@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=will.deacon@arm.com \
    --subject='Re: [PATCH v2 2/5] crypto: ccree: better clock handling' \
    /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

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).