linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 10/10] clk: copy parent_names in clk-mux registration
Date: Tue, 27 Mar 2012 15:23:29 +0800	[thread overview]
Message-ID: <1332833009-4121-11-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1332833009-4121-1-git-send-email-shawn.guo@linaro.org>

Just like what all other basic clks do, copy parent_names in clk-mux
registration, so that clock driver can mark the parent_names
__initconst.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/clk/clk-mux.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 1ff90a6..353fcb7 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -94,6 +94,9 @@ struct clk *clk_register_mux(struct device *dev, const char *name,
 		u8 clk_mux_flags, spinlock_t *lock)
 {
 	struct clk_mux *mux;
+	struct clk *clk;
+	const char **parents = NULL;
+	int i = 0;
 
 	mux = kzalloc(sizeof(struct clk_mux), GFP_KERNEL);
 
@@ -109,6 +112,28 @@ struct clk *clk_register_mux(struct device *dev, const char *name,
 	mux->flags = clk_mux_flags;
 	mux->lock = lock;
 
-	return clk_register(dev, name, &clk_mux_ops, &mux->hw,
-			parent_names, num_parents, flags);
+	if (num_parents) {
+		parents = kzalloc(sizeof(char *) * num_parents, GFP_KERNEL);
+		if (!parents)
+			goto out;
+
+		for (i = 0; i < num_parents; i++) {
+			parents[i] = kstrdup(parent_names[i], GFP_KERNEL);
+			if (!parents[i])
+				goto out;
+		}
+	}
+
+	clk =  clk_register(dev, name, &clk_mux_ops, &mux->hw,
+			parents, num_parents, flags);
+	if (clk)
+		return clk;
+
+out:
+	for (i--; i >= 0; i--)
+		kfree(parents[i]);
+	kfree(parents);
+	kfree(mux);
+
+	return NULL;
 }
-- 
1.7.5.4

  parent reply	other threads:[~2012-03-27  7:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-27  7:23 [PATCH 00/10] clk: cleanup on basic clks Shawn Guo
2012-03-27  7:23 ` [PATCH 01/10] clk: use kzalloc in clk_register_mux Shawn Guo
2012-03-27 23:31   ` Turquette, Mike
2012-03-27  7:23 ` [PATCH 02/10] clk: remove unnecessary EXPORT_SYMBOL_GPL Shawn Guo
2012-03-27  7:23 ` [PATCH 03/10] clk: add "const" for clk_ops of basic clks Shawn Guo
2012-03-27 23:29   ` Turquette, Mike
2012-03-27  7:23 ` [PATCH 04/10] clk: declare clk_ops of basic clks in clk-provider.h Shawn Guo
2012-03-28 21:20   ` Turquette, Mike
2012-03-27  7:23 ` [PATCH 05/10] clk: align error return of basic clks registeration Shawn Guo
2012-03-27 23:28   ` Turquette, Mike
2012-03-27  7:23 ` [PATCH 06/10] clk: fixed-rate: Don't open code kstrdup() Shawn Guo
2012-03-27 23:36   ` Turquette, Mike
2012-03-27  7:23 ` [PATCH 07/10] clk: Constify parent name arrays Shawn Guo
2012-03-28  1:03   ` Turquette, Mike
2012-03-28 10:07     ` Mark Brown
2012-03-27  7:23 ` [PATCH 08/10] clk: fixed-rate: registration error handling fixup Shawn Guo
2012-03-28  0:31   ` Turquette, Mike
2012-03-27  7:23 ` [PATCH 09/10] clk: dynamically allocate parent_names basic clk registration Shawn Guo
2012-03-27  8:55   ` Sascha Hauer
2012-03-27 12:51     ` Shawn Guo
2012-03-27 19:40       ` Sascha Hauer
2012-03-27 23:17         ` Turquette, Mike
2012-03-27  7:23 ` Shawn Guo [this message]
2012-04-09 22:00   ` [PATCH 10/10] clk: copy parent_names in clk-mux registration Turquette, Mike

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=1332833009-4121-11-git-send-email-shawn.guo@linaro.org \
    --to=shawn.guo@linaro.org \
    --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).