From: Brian Masney <bmasney@redhat.com>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Maxime Ripard <mripard@kernel.org>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Conor Dooley <conor@kernel.org>,
Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Brian Masney <bmasney@redhat.com>,
kernel test robot <lkp@intel.com>
Subject: [PATCH v3 2/4] clk: microchip: core: correct return value on *_get_parent()
Date: Fri, 05 Dec 2025 14:46:28 -0500 [thread overview]
Message-ID: <20251205-clk-microchip-fixes-v3-2-a02190705e47@redhat.com> (raw)
In-Reply-To: <20251205-clk-microchip-fixes-v3-0-a02190705e47@redhat.com>
roclk_get_parent() and sclk_get_parent() has the possibility of
returning -EINVAL, however the framework expects this call to always
succeed since the return value is unsigned.
If there is no parent map defined, then the current value programmed in
the hardware is used. Let's use that same value in the case where
-EINVAL is currently returned.
This index is only used by clk_core_get_parent_by_index(), and it
validates that it doesn't overflow the number of available parents.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202512050233.R9hAWsJN-lkp@intel.com/
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
drivers/clk/microchip/clk-core.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/clk/microchip/clk-core.c b/drivers/clk/microchip/clk-core.c
index a0163441dfe5c1dfc27dae48e64cf3cb3d6b764f..82f62731fc0ed566b0c6b007381c4f10a2a8a7e7 100644
--- a/drivers/clk/microchip/clk-core.c
+++ b/drivers/clk/microchip/clk-core.c
@@ -283,14 +283,13 @@ static u8 roclk_get_parent(struct clk_hw *hw)
v = (readl(refo->ctrl_reg) >> REFO_SEL_SHIFT) & REFO_SEL_MASK;
- if (!refo->parent_map)
- return v;
-
- for (i = 0; i < clk_hw_get_num_parents(hw); i++)
- if (refo->parent_map[i] == v)
- return i;
+ if (refo->parent_map) {
+ for (i = 0; i < clk_hw_get_num_parents(hw); i++)
+ if (refo->parent_map[i] == v)
+ return i;
+ }
- return -EINVAL;
+ return v;
}
static unsigned long roclk_calc_rate(unsigned long parent_rate,
@@ -817,13 +816,13 @@ static u8 sclk_get_parent(struct clk_hw *hw)
v = (readl(sclk->mux_reg) >> OSC_CUR_SHIFT) & OSC_CUR_MASK;
- if (!sclk->parent_map)
- return v;
+ if (sclk->parent_map) {
+ for (i = 0; i < clk_hw_get_num_parents(hw); i++)
+ if (sclk->parent_map[i] == v)
+ return i;
+ }
- for (i = 0; i < clk_hw_get_num_parents(hw); i++)
- if (sclk->parent_map[i] == v)
- return i;
- return -EINVAL;
+ return v;
}
static int sclk_set_parent(struct clk_hw *hw, u8 index)
--
2.52.0
next prev parent reply other threads:[~2025-12-05 19:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 19:46 [PATCH v3 0/4] clk: microchip: core: fix issue with round_rate conversion and allow compile test Brian Masney
2025-12-05 19:46 ` [PATCH v3 1/4] clk: microchip: core: remove duplicate determine_rate on pic32_sclk_ops Brian Masney
2025-12-06 14:30 ` Claudiu Beznea
2025-12-05 19:46 ` Brian Masney [this message]
2025-12-06 14:31 ` [PATCH v3 2/4] clk: microchip: core: correct return value on *_get_parent() Claudiu Beznea
2025-12-06 22:38 ` Brian Masney
2025-12-05 19:46 ` [PATCH v3 3/4] clk: microchip: core: remove unused include asm/traps.h Brian Masney
2025-12-05 19:46 ` [PATCH v3 4/4] clk: microchip: core: allow driver to be compiled with COMPILE_TEST Brian Masney
2025-12-06 14:28 ` Claudiu Beznea
2025-12-19 19:32 ` Brian Masney
2026-01-09 7:13 ` claudiu beznea
2026-01-08 23:15 ` [PATCH v3 0/4] clk: microchip: core: fix issue with round_rate conversion and allow compile test Brian Masney
2026-01-09 7:16 ` claudiu beznea
2026-01-09 11:30 ` Brian Masney
2026-01-09 16:45 ` Brian Masney
2026-01-10 14:59 ` Claudiu Beznea
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=20251205-clk-microchip-fixes-v3-2-a02190705e47@redhat.com \
--to=bmasney@redhat.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=conor@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mripard@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
all inboxes | Powered by JetHome®