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)
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;