OSDN Git Service

regmap: Skip clk_put for attached clocks when freeing context
authorJames Kelly <jamespeterkelly@gmail.com>
Tue, 15 May 2018 00:59:58 +0000 (10:59 +1000)
committerMark Brown <broonie@kernel.org>
Thu, 17 May 2018 07:11:41 +0000 (16:11 +0900)
Capability to attach an existing clk to a MMIO regmap was
introduced in 4.17rc1.

However, when using attached clk, regmap does not do the clk_get.
Therefore it should not do the clk_put when freeing the MMIO
regmap context.

There does not appear to be any users of attached clocks yet
so this would be a good time to make this change before anything
depends on the existing behaviour.

Signed-off-by: James Kelly <jamespeterkelly@gmail.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap-mmio.c

index 5cadfd3..8741fb5 100644 (file)
@@ -206,7 +206,8 @@ static void regmap_mmio_free_context(void *context)
 
        if (!IS_ERR(ctx->clk)) {
                clk_unprepare(ctx->clk);
-               clk_put(ctx->clk);
+               if (!ctx->attached_clk)
+                       clk_put(ctx->clk);
        }
        kfree(context);
 }