From: Magnus Damm <magnus.damm@gmail.com>
To: linux-clk@vger.kernel.org
Cc: linux-sh@vger.kernel.org,mturquette@baylibre.com,sboyd@codeaurora.org,horms@verge.net.au,geert@linux-m68k.org,laurent.pinchart@ideasonboard.com,Magnus
Damm <magnus.damm@gmail.com>
Subject: [PATCH 03/05][RFC] clk: Allow NULL as parent names
Date: Tue, 15 Sep 2015 19:23:07 +0900 [thread overview]
Message-ID: <20150915102307.15716.26976.sendpatchset@little-apple> (raw)
In-Reply-To: <20150915102238.15716.91170.sendpatchset@little-apple>
From: Magnus Damm <damm+renesas@opensource.se>
Relax the parent name requirement now when struct clk_init_data
allows passing in an array of parent clocks during registration.
With this patch the parent name pointer can be set to NULL in
case parent clocks instead are passed in the parent array.
TODO: Check if kfree_const() cleanup code needs to be updated.
Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
---
drivers/clk/clk.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
--- 0003/drivers/clk/clk.c
+++ work/drivers/clk/clk.c 2015-09-15 18:32:55.420513000 +0900
@@ -1081,7 +1081,8 @@ static int clk_fetch_parent_index(struct
if (core->parents[i])
continue;
- if (!strcmp(core->parent_names[i], parent->name)) {
+ if (core->parent_names[i] && !strcmp(core->parent_names[i],
+ parent->name)) {
core->parents[i] = clk_core_lookup(parent->name);
return i;
}
@@ -1675,7 +1676,7 @@ static struct clk_core *__clk_init_paren
if (core->num_parents == 1) {
if (IS_ERR_OR_NULL(core->parent))
- core->parent = clk_core_lookup(core->parent_names[0]);
+ core->parent = clk_core_get_parent_by_index(core, 0);
ret = core->parent;
goto out;
}
@@ -1749,7 +1750,8 @@ bool clk_has_parent(struct clk *clk, str
return true;
for (i = 0; i < core->num_parents; i++)
- if (strcmp(core->parent_names[i], parent_core->name) == 0)
+ if (core->parent_names[i] && strcmp(core->parent_names[i],
+ parent_core->name) == 0)
return true;
return false;
@@ -2337,7 +2339,7 @@ static int __clk_init(struct device *dev
/* throw a WARN if any entries in parent_names are NULL */
for (i = 0; i < core->num_parents; i++)
- WARN(!core->parent_names[i],
+ WARN(!core->parents && !core->parent_names[i],
"%s: invalid NULL in %s's .parent_names\n",
__func__, core->name);
@@ -2437,13 +2439,15 @@ static int __clk_init(struct device *dev
hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
if (orphan->num_parents && orphan->ops->get_parent) {
i = orphan->ops->get_parent(orphan->hw);
- if (!strcmp(core->name, orphan->parent_names[i]))
+ if (orphan->parent_names[i] &&
+ !strcmp(core->name, orphan->parent_names[i]))
clk_core_reparent(orphan, core);
continue;
}
for (i = 0; i < orphan->num_parents; i++)
- if (!strcmp(core->name, orphan->parent_names[i])) {
+ if (orphan->parent_names[i] &&
+ !strcmp(core->name, orphan->parent_names[i])) {
clk_core_reparent(orphan, core);
break;
}
@@ -2555,6 +2559,9 @@ struct clk *clk_register(struct device *
/* copy each string name in case parent_names is __initdata */
for (i = 0; i < core->num_parents; i++) {
+ if (!hw->init->parent_names[i])
+ continue;
+
core->parent_names[i] = kstrdup_const(hw->init->parent_names[i],
GFP_KERNEL);
if (!core->parent_names[i]) {
next prev parent reply other threads:[~2015-09-15 10:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-15 10:22 [PATCH 00/05][RFC] Clock registration without parent name Magnus Damm
2015-09-15 10:22 ` [PATCH 01/05][RFC] clk: Initialize on-stack struct clk_init_data Magnus Damm
2015-09-15 10:22 ` [PATCH 02/05][RFC] clk: Add parent array to " Magnus Damm
2015-09-15 10:23 ` Magnus Damm [this message]
2015-09-15 10:23 ` [PATCH 04/05][RFC] clk: fixed-factor: Pass " Magnus Damm
2015-09-15 10:23 ` [PATCH 05/05][RFC] clk: fixed-factor: Make use of parent array Magnus Damm
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=20150915102307.15716.26976.sendpatchset@little-apple \
--to=magnus.damm@gmail.com \
--cc=geert@linux-m68k.org \
--cc=horms@verge.net.au \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@codeaurora.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