lkml.org 
[lkml]   [2019]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] clk: mux: check mux value after set
Date
From: Peng Fan <peng.fan@nxp.com>

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@nxp.com>
---
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
\
 
 \ /
  Last update: 2019-12-18 10:44    [W:0.029 / U:10.804 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site