[PATCH] clk: uniphier: mux: fix signedness bug in get_parent

Anas Iqbal
2026-03-18T11:07:34Z

The uniphier_clk_mux_get_parent() function returns a u8, but
propagates negative error codes such as -EINVAL and regmap_read()
failures. These values are implicitly converted to large unsigned
integers, resulting in invalid parent indices.

The clk_ops.get_parent() callback is expected to return a valid
parent index and does not support error codes. Fix this by returning
0 as a safe fallback in error cases.

Fixes: 734d82f4a678 ("clk: uniphier: add core support code for UniPhier clock driver")
Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
---
drivers/clk/uniphier/clk-uniphier-mux.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/uniphier/clk-uniphier-mux.c b/drivers/clk/uniphier/clk-uniphier-mux.c
index 1998e9d4cfc0..f3b21ea96649 100644
--- a/drivers/clk/uniphier/clk-uniphier-mux.c
+++ b/drivers/clk/uniphier/clk-uniphier-mux.c
@@ -38,13 +38,13 @@ static u8 uniphier_clk_mux_get_parent(struct clk_hw *hw)

ret = regmap_read(mux->regmap, mux->reg, &val);
if (ret)
- return ret;
+ return 0; /* fallback to parent 0 on error */

for (i = 0; i < num_parents; i++)
if ((mux->masks[i] & val) == mux->vals[i])
return i;

- return -EINVAL;
+ return 0; /* default fallback */
}

static const struct clk_ops uniphier_clk_mux_ops = {
--
2.43.0