From: Christian Marangi <ansuelsmth@gmail.com>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Christian Marangi <ansuelsmth@gmail.com>
Subject: [PATCH v2 1/2] clk: Warn and add workaround on misuse of .parent_data with .name only
Date: Tue, 31 Jan 2023 17:08:28 +0100 [thread overview]
Message-ID: <20230131160829.23369-1-ansuelsmth@gmail.com> (raw)
By a simple mistake in a .parent_names to .parent_data conversion it was
found that clk core assume fw_name is always provided with a parent_data
struct for each parent and never fallback to .name to get parent name even
if declared.
This is caused by clk_core_get that only checks for parent .fw_name and
doesn't handle .name.
While it's sane to request the dev to correctly do the conversion and
add both .fw_name and .name in a parent_data struct, it's not sane to
silently drop parents without a warning.
Fix this in 2 ways. Add a kernel warning when a wrong implementation is
used and copy .name in .fw_name in parent map populate function to
handle clk problems and malfunctions.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/clk/clk.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 57b83665e5c3..dccd4ea6f692 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -4015,10 +4015,21 @@ static int clk_core_populate_parent_map(struct clk_core *core,
ret = clk_cpy_name(&parent->name, parent_names[i],
true);
} else if (parent_data) {
+ const char *parent_name;
+
parent->hw = parent_data[i].hw;
parent->index = parent_data[i].index;
+ parent_name = parent_data[i].fw_name;
+
+ if (!parent_name && parent_data[i].name) {
+ WARN(1, "Empty .fw_name with .name in %s's .parent_data. Using .name for .fw_name declaration.\n",
+ core->name);
+ parent_name = parent_data[i].name;
+ }
+
ret = clk_cpy_name(&parent->fw_name,
- parent_data[i].fw_name, false);
+ parent_name, false);
+
if (!ret)
ret = clk_cpy_name(&parent->name,
parent_data[i].name,
--
2.38.1
next reply other threads:[~2023-01-31 16:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 16:08 Christian Marangi [this message]
2023-01-31 16:08 ` [PATCH v2 2/2] clk: gate: Add missing fw_name for clk_gate_register_test_parent_data_legacy Christian Marangi
2023-02-11 0:52 ` Stephen Boyd
2023-02-10 18:39 ` Christian Marangi
2023-02-11 0:40 ` [PATCH v2 1/2] clk: Warn and add workaround on misuse of .parent_data with .name only Stephen Boyd
2023-02-10 18:34 ` Christian Marangi
2023-02-15 18:54 ` Stephen Boyd
2023-02-15 23:33 ` Christian Marangi
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=20230131160829.23369-1-ansuelsmth@gmail.com \
--to=ansuelsmth@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.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