diff options
author | Bastian Krause <bst@pengutronix.de> | 2022-05-11 12:09:11 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-05-12 09:03:25 +0200 |
commit | 9c5149713e7f9964183ab5b424950ba4291a63a1 (patch) | |
tree | 88564dbd2a320323df699422e7db021b1cb41564 /drivers/clk | |
parent | 2d7b49c1e7ee5ff5cd67be3ebf100d7b3c9ae293 (diff) | |
download | barebox-9c5149713e7f9964183ab5b424950ba4291a63a1.tar.gz barebox-9c5149713e7f9964183ab5b424950ba4291a63a1.tar.xz |
clk: handle NULL args in clk_set_parent()
NULL struct clk pointers should be treated just as the Linux kernel clk
driver does [1]. The reasoning should also apply to the parent clk
argument.
A NULL struct clk pointer can happen for example on the Freescale i.MX6
SABRE Smart Device Board if CONFIG_DRIVER_VIDEO_IMX_IPUV3 is disabled,
leading to assigned-clocks IMX6QDL_CLK_LDB_DI0_SEL and
IMX6QDL_CLK_LDB_DI1_SEL [2] being unavailable. Without this patch, the
board hangs while setting those assigned clock configurations since [3].
[1] 89ac8d7ae1cd ("clk: handle NULL struct clk gracefully")
[2] dts/src/arm/imx6qdl-sabresd.dtsi
[3] f5eb5fddb4 ("clk: fix of clk set defaults when dev is a clk provider")
Signed-off-by: Bastian Krause <bst@pengutronix.de>
Link: https://lore.barebox.org/20220511100911.2009482-1-bst@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 8e317b4b05..efb5d4ad4a 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -230,7 +230,10 @@ int clk_set_parent(struct clk *clk, struct clk *newparent) { struct clk_hw *hw; int i, ret; - struct clk *curparent = clk_get_parent(clk); + struct clk *curparent; + + if (!clk || !newparent) + return 0; if (IS_ERR(clk)) return PTR_ERR(clk); @@ -254,6 +257,8 @@ int clk_set_parent(struct clk *clk, struct clk *newparent) if (i == clk->num_parents) return -EINVAL; + curparent = clk_get_parent(clk); + if (clk->enable_count) clk_enable(newparent); |