Thread (8 messages) 8 messages, 3 authors, 2020-11-02
STALE2074d

[PATCH v2 5/5] clk: imx: gate2: Add locking in is_enabled op

From: Abel Vesa <hidden>
Date: 2020-10-28 22:26:05
Also in: linux-clk, linux-devicetree, lkml
Subsystem: common clk framework, nxp i.mx clock drivers, the rest · Maintainers: Michael Turquette, Stephen Boyd, Abel Vesa, Linus Torvalds

Protect against enabling/disabling the gate while we're
checking if it is enabled.

Signed-off-by: Abel Vesa <redacted>
---
 drivers/clk/imx/clk-gate2.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/imx/clk-gate2.c b/drivers/clk/imx/clk-gate2.c
index 7e4b5e8..480a184 100644
--- a/drivers/clk/imx/clk-gate2.c
+++ b/drivers/clk/imx/clk-gate2.c
@@ -101,9 +101,17 @@ static int clk_gate2_reg_is_enabled(void __iomem *reg, u8 bit_idx,
 static int clk_gate2_is_enabled(struct clk_hw *hw)
 {
 	struct clk_gate2 *gate = to_clk_gate2(hw);
+	unsigned long flags;
+	int ret = 0;
 
-	return clk_gate2_reg_is_enabled(gate->reg, gate->bit_idx,
+	spin_lock_irqsave(gate->lock, flags);
+
+	ret = clk_gate2_reg_is_enabled(gate->reg, gate->bit_idx,
 					gate->cgr_val, gate->cgr_mask);
+
+	spin_unlock_irqrestore(gate->lock, flags);
+
+	return ret;
 }
 
 static void clk_gate2_disable_unused(struct clk_hw *hw)
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help