[PATCH] clk: bcm: kona: Stop defaulting to parent index 0 on error

Yu-Chun Lin posted 1 patch 1 week ago
drivers/clk/bcm/clk-kona.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] clk: bcm: kona: Stop defaulting to parent index 0 on error
Posted by Yu-Chun Lin 1 week ago
Stop defaulting to 0 on BAD_CLK_INDEX (U8_MAX). Passing the out-of-bounds
index directly allows the clk core to fail gracefully during parent
lookup.

Link: https://lore.kernel.org/lkml/177431305509.5403.15386021337517970667@lazor/
Signed-off-by: Yu-Chun Lin <eleanor.lin@realtek.com>
---
 drivers/clk/bcm/clk-kona.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c
index 0171e6b2bfca..d6f5872d7d6a 100644
--- a/drivers/clk/bcm/clk-kona.c
+++ b/drivers/clk/bcm/clk-kona.c
@@ -1098,8 +1098,7 @@ static u8 kona_peri_clk_get_parent(struct clk_hw *hw)
 
 	index = selector_read_index(bcm_clk->ccu, &data->sel);
 
-	/* Not all callers would handle an out-of-range value gracefully */
-	return index == BAD_CLK_INDEX ? 0 : index;
+	return index;
 }
 
 static int kona_peri_clk_set_rate(struct clk_hw *hw, unsigned long rate,
-- 
2.49.0
Re: [PATCH] clk: bcm: kona: Stop defaulting to parent index 0 on error
Posted by Brian Masney 6 days, 14 hours ago
On Sun, May 31, 2026 at 09:18:25PM +0800, Yu-Chun Lin wrote:
> Stop defaulting to 0 on BAD_CLK_INDEX (U8_MAX). Passing the out-of-bounds
> index directly allows the clk core to fail gracefully during parent
> lookup.
> 
> Link: https://lore.kernel.org/lkml/177431305509.5403.15386021337517970667@lazor/
> Signed-off-by: Yu-Chun Lin <eleanor.lin@realtek.com>

Reviewed-by: Brian Masney <bmasney@redhat.com>