From: Yang Xiwen Date: Sat, 16 Dec 2023 02:28:51 +0800 Subject: [PATCH v3 1/2] clk: get correct ops for clk_enable() and clk_disable() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231111-enable_count-v3-1-08a821892fa9@outlook.com> References: <20231111-enable_count-v3-0-08a821892fa9@outlook.com> In-Reply-To: <20231111-enable_count-v3-0-08a821892fa9@outlook.com> To: Simon Glass , Lukasz Majewski , Sean Anderson Cc: u-boot@lists.denx.de, Yang Xiwen X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1702664931; l=1187; i=forbidden405@outlook.com; s=20230415; h=from:subject:message-id; bh=lkdm+vGFt2P1kjUtpjLgf/OGQ+pcAmah4UJq3vZOUKo=; b=u12vzkE9QuN3ZZXQtTBniKgdXhe++J0aMWLWLQtVMWTzn978jWpRKO1/zAh31UG27eRuEdkOP /aF4/s/o+xaDc6+ELs9aPSqzeW8xW99iEElwu5iQXZi+EjouJrDUVJV X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=hfdpPU3AXR+t7fdv58tXCD4UzRNq+fop2TMJezFlAhM= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230415 with auth_id=44 List-Id: B4 Relay Submissions assign clk_dev_ops(clkp->dev) to ops to ensure correct clk operations are called on clocks. This fixes the incorrect enable_count issue as described in [1]. [1]: https://lore.kernel.org/all/SEZPR06MB695927A6DEEEF8489A06897396A7A@SEZPR06MB6959.apcprd06.prod.outlook.com/ Reviewed-by: Sean Anderson Signed-off-by: Yang Xiwen --- drivers/clk/clk-uclass.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 3b5e3f9c86..3e9d68feb3 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -640,6 +640,7 @@ int clk_enable(struct clk *clk) if (CONFIG_IS_ENABLED(CLK_CCF)) { /* Take id 0 as a non-valid clk, such as dummy */ if (clk->id && !clk_get_by_id(clk->id, &clkp)) { + ops = clk_dev_ops(clkp->dev); if (clkp->enable_count) { clkp->enable_count++; return 0; @@ -699,6 +700,7 @@ int clk_disable(struct clk *clk) if (CONFIG_IS_ENABLED(CLK_CCF)) { if (clk->id && !clk_get_by_id(clk->id, &clkp)) { + ops = clk_dev_ops(clkp->dev); if (clkp->flags & CLK_IS_CRITICAL) return 0; -- 2.39.2