]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ENGR00329352-1 regmap: regmap-mmio: make clk_id optionally when getting clock
authorDong Aisheng <b29396@freescale.com>
Wed, 27 Aug 2014 07:55:59 +0000 (15:55 +0800)
committerNitin Garg <nitin.garg@freescale.com>
Fri, 16 Jan 2015 03:17:07 +0000 (21:17 -0600)
According to clock framework, the clk_id could be NULL when getting clock.
But current code relies on a non null clk_id to get clock.
Changing the code to allow a null clk_id to get clock to make it more
reasonable to use.
And the regmap_mmio_gen_context will try to get clock by default but ignore
error if not finding the clock in case some regmap access not reply on
a specific clock.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
(cherry picked from commit e94692d02c66c87c246af3b7c311d02a2d04c739)

drivers/base/regmap/regmap-mmio.c

index 81f977510775460fa2bf8b0bd500c69027c02274..8919a72ffb3f219b71fdb6e3bdc10b98be988aa1 100644 (file)
@@ -211,19 +211,15 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
        ctx->val_bytes = config->val_bits / 8;
        ctx->clk = ERR_PTR(-ENODEV);
 
-       if (clk_id == NULL)
-               return ctx;
-
        ctx->clk = clk_get(dev, clk_id);
-       if (IS_ERR(ctx->clk)) {
-               ret = PTR_ERR(ctx->clk);
-               goto err_free;
-       }
-
-       ret = clk_prepare(ctx->clk);
-       if (ret < 0) {
-               clk_put(ctx->clk);
-               goto err_free;
+       if (!IS_ERR(ctx->clk)) {
+               ret = clk_prepare(ctx->clk);
+               if (ret < 0) {
+                       clk_put(ctx->clk);
+                       goto err_free;
+               }
+       } else {
+               ctx->clk = NULL;
        }
 
        return ctx;