diff options
author | Abel Vesa <abel.vesa@nxp.com> | 2020-10-28 14:59:02 +0200 |
---|---|---|
committer | Shawn Guo <shawnguo@kernel.org> | 2020-11-03 07:55:41 +0800 |
commit | 65188f07456d4a65b4a66069a701823878e098ff (patch) | |
tree | 44e73689406f400308f7282c20bc2ea279d9b3c2 /drivers/clk/imx | |
parent | bcd418a632b621510ebc731cb707d8fe3e873119 (diff) |
clk: imx: gate2: Add locking in is_enabled op
Protect against enabling/disabling the gate while we're
checking if it is enabled.
Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
Diffstat (limited to 'drivers/clk/imx')
-rw-r--r-- | drivers/clk/imx/clk-gate2.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/clk/imx/clk-gate2.c b/drivers/clk/imx/clk-gate2.c index 7e4b5e82de7f..480a184207d5 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; + + spin_lock_irqsave(gate->lock, flags); - return clk_gate2_reg_is_enabled(gate->reg, gate->bit_idx, + 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) |