mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] clk: Treat NULL as dummy clocks
Date: Thu,  5 Mar 2015 15:17:17 +0100	[thread overview]
Message-ID: <1425565037-9348-1-git-send-email-s.hauer@pengutronix.de> (raw)

NULL pointers should be treated as dummy clocks as done in the kernel.
Using a not fully filled in clk * array for of_clk_add_provider may result
in NULL clks. When these are passed into the clk framework we should not
crash.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/clk/clk.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 584e2f3..1f11bb3 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -44,6 +44,9 @@ int clk_enable(struct clk *clk)
 {
 	int ret;
 
+	if (!clk)
+		return 0;
+
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
@@ -68,6 +71,9 @@ int clk_enable(struct clk *clk)
 
 void clk_disable(struct clk *clk)
 {
+	if (!clk)
+		return;
+
 	if (IS_ERR(clk))
 		return;
 
@@ -89,10 +95,15 @@ unsigned long clk_get_rate(struct clk *clk)
 	struct clk *parent;
 	unsigned long parent_rate = 0;
 
+	if (!clk)
+		return 0;
+
 	if (IS_ERR(clk))
 		return 0;
 
 	parent = clk_get_parent(clk);
+
+
 	if (!IS_ERR_OR_NULL(parent))
 		parent_rate = clk_get_rate(parent);
 
@@ -107,6 +118,9 @@ long clk_round_rate(struct clk *clk, unsigned long rate)
 	unsigned long parent_rate = 0;
 	struct clk *parent;
 
+	if (!clk)
+		return 0;
+
 	if (IS_ERR(clk))
 		return 0;
 
@@ -125,6 +139,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
 	struct clk *parent;
 	unsigned long parent_rate = 0;
 
+	if (!clk)
+		return 0;
+
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2015-03-05 14:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1425565037-9348-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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