linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] clk: Add helper to get/put arrays of clocks
Date: Thu,  8 Mar 2012 22:42:28 +0100	[thread overview]
Message-ID: <1331242949-22780-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1331242949-22780-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/clk/clkdev.c |   36 ++++++++++++++++++++++++++++++++++++
 include/linux/clk.h  |    3 +++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 6db161f..c661395 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -89,6 +89,42 @@ void clk_put(struct clk *clk)
 }
 EXPORT_SYMBOL(clk_put);
 
+int clk_get_array(struct device *dev, struct clk **clks, const char **names,
+		int numclks, bool msg)
+{
+	int i, ret;
+
+	for (i = 0; i < numclks; i++) {
+		clks[i] = clk_get(dev, names[i]);
+		if (IS_ERR(clks[i])) {
+			if (msg)
+				dev_err(dev, "getting clock \"%s\" failed with %d\n",
+						names[i] ? names[i] : "",
+						PTR_ERR(clks[i]));
+			ret = PTR_ERR(clks[i]);
+			goto err;
+		}
+	}
+
+	return 0;
+err:
+	while (i > 0) {
+		i--;
+		clk_put(clks[i]);
+	}
+	return ret;
+}
+EXPORT_SYMBOL(clk_get_array);
+
+void clk_put_array(struct clk **clks, int numclks)
+{
+	int i;
+
+	for (i = 0; i < numclks; i++)
+		clk_put(clks[i]);
+}
+EXPORT_SYMBOL(clk_put_array);
+
 void clkdev_add(struct clk_lookup *cl)
 {
 	mutex_lock(&clocks_mutex);
diff --git a/include/linux/clk.h b/include/linux/clk.h
index b9d46fa..1584cbd 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -148,6 +148,9 @@ unsigned long clk_get_rate(struct clk *clk);
  */
 void clk_put(struct clk *clk);
 
+int clk_get_array(struct device *dev, struct clk **clks, const char **names,
+		int numclks, bool msg);
+void clk_put_array(struct clk **clks, int numclks);
 
 /*
  * The remaining APIs are optional for machine class support.
-- 
1.7.9.1

  reply	other threads:[~2012-03-08 21:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-08 21:42 [RFC] i.MX: drop secondary clocks Sascha Hauer
2012-03-08 21:42 ` Sascha Hauer [this message]
2012-03-08 21:42 ` [PATCH 2/2] spi i.MX: do not depend on grouped clocks Sascha Hauer
2012-03-09  8:03 ` [RFC] i.MX: drop secondary clocks Shawn Guo
2012-03-09  9:32 ` Lothar Waßmann
2012-03-09 10:29   ` Sascha Hauer
2012-03-09 11:47     ` Lothar Waßmann
2012-03-09 14:20       ` Richard Zhao
2012-03-09 14:22       ` Sascha Hauer
2012-03-09 14:44         ` Lothar Waßmann
2012-03-09 16:09           ` Sascha Hauer

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=1331242949-22780-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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).