summaryrefslogtreecommitdiff
path: root/drivers/clk/clk-composite.c
diff options
context:
space:
mode:
authorSean Anderson <seanga2@gmail.com>2020-06-24 13:41:06 +0300
committerAndes <uboot@andestech.com>2020-07-01 10:01:21 +0300
commit78ce0bd3acafc51e94157ff99aec3ed82e685ef5 (patch)
tree64817268c219072add6e2364952f27c66e16724f /drivers/clk/clk-composite.c
parente2a4d24e6b1f3d30136e2dde7b6fbf35bd427b8a (diff)
downloadu-boot-78ce0bd3acafc51e94157ff99aec3ed82e685ef5.tar.xz
clk: Always use the supplied struct clk
CCF clocks should always use the struct clock passed to their methods for extracting the driver-specific clock information struct. Previously, many functions would use the clk->dev->priv if the device was bound. This could cause problems with composite clocks. The individual clocks in a composite clock did not have the ->dev field filled in. This was fine, because the device-specific clock information would be used. However, since there was no ->dev, there was no way to get the parent clock. This caused the recalc_rate method of the CCF divider clock to fail. One option would be to use the clk->priv field to get the composite clock and from there get the appropriate parent device. However, this would tie the implementation to the composite clock. In general, different devices should not rely on the contents of ->priv from another device. The simple solution to this problem is to just always use the supplied struct clock. The composite clock now fills in the ->dev pointer of its child clocks. This allows child clocks to make calls like clk_get_parent() without issue. imx avoided the above problem by using a custom get_rate function with composite clocks. Signed-off-by: Sean Anderson <seanga2@gmail.com> Acked-by: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'drivers/clk/clk-composite.c')
-rw-r--r--drivers/clk/clk-composite.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index 414185031e..2ff1d6b47f 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -147,6 +147,13 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
goto err;
}
+ if (composite->mux)
+ composite->mux->dev = clk->dev;
+ if (composite->rate)
+ composite->rate->dev = clk->dev;
+ if (composite->gate)
+ composite->gate->dev = clk->dev;
+
return clk;
err: