linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: mux: check mux value after set
@ 2019-12-18  9:44 Peng Fan
  0 siblings, 0 replies; only message in thread
From: Peng Fan @ 2019-12-18  9:44 UTC (permalink / raw)
  To: sboyd; +Cc: linux-clk, linux-kernel, Peng Fan

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-12-18  9:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18  9:44 [PATCH] clk: mux: check mux value after set Peng Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).