[PATCH] clk: mux: check mux value after set
From: Peng Fan
Date: Wed Dec 18 2019 - 04:44:28 EST
From: Peng Fan <peng.fan@xxxxxxx>
check mux value after set to see whether it failed or not.
To some platforms, it might failed to set the mux value because
of the hardware not allow the change, let's catch such case and report,
then it will be easy for us the catch issue.
Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
---
drivers/clk/clk-mux.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 570b6e5b603b..3e78ec65bffb 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -101,6 +101,7 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
u32 val = clk_mux_index_to_val(mux->table, mux->flags, index);
unsigned long flags = 0;
u32 reg;
+ int ret = 0;
if (mux->lock)
spin_lock_irqsave(mux->lock, flags);
@@ -117,12 +118,15 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
reg |= val;
clk_mux_writel(mux, reg);
+ if (clk_mux_get_parent(hw) != index)
+ ret = -EPERM;
+
if (mux->lock)
spin_unlock_irqrestore(mux->lock, flags);
else
__release(mux->lock);
- return 0;
+ return ret;
}
static int clk_mux_determine_rate(struct clk_hw *hw,
--
2.16.4