clk: handle NULL args in clk_{g,s}et_parent()
PATCH v2 1/1 clk: handle NULL args in clk_{g,s}et_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")
---
Changes since (implicit) v1:
- make clk_get_parent(NULL) return NULL
- undo shifting call to clk_get_parent() in clk_set_parent()
--- drivers/clk/clk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clk/clk.c +4 -1
@@ -232,6 +232,9 @@ int clk_set_parent(struct clk *clk, struct clk *newparent)int i, ret;struct clk *curparent =clk_get_parent (clk); +if (!clk || !newparent) +return 0 ; +if (IS_ERR (clk))return PTR_ERR (clk);if (IS_ERR (newparent))
@@ -287,7 +290,7 @@ struct clk *clk_get_parent(struct clk *clk)struct clk_hw *hw;int idx; -if (IS_ERR (clk)) +if (IS_ERR_OR_NULL (clk))return clk;if (!clk->num_parents)
Signature · 7 lines
2.30.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 10 lines · Bastian Krause
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_IPUV3is disabled, leading to assigned-clocksIMX6QDL_CLK_LDB_DI0_SELandIMX6QDL_CLK_LDB_DI1_SEL[2] being unavailable. Without this patch, the board hangs while setting those assigned clock configurations since [3].
Quoted 5 lines
[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 <[email protected]>
Quoted 31 lines
---
Changes since (implicit) v1:
- makeclk_get_parent(NULL)return NULL
- undo shifting call toclk_get_parent()inclk_set_parent()--- drivers/clk/clk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/clk/clk.c +4
-1@@ -232,6 +232,9 @@ int clk_set_parent(struct clk *clk, struct clk *newparent)int i, ret;struct clk *curparent =clk_get_parent (clk); +if (!clk || !newparent) +return 0 ; +if (IS_ERR (clk))return PTR_ERR (clk);if (IS_ERR (newparent))@@ -287,7 +290,7 @@ struct clk *clk_get_parent(struct clk *clk)struct clk_hw *hw;int idx; -if (IS_ERR (clk)) +if (IS_ERR_OR_NULL (clk))return clk;if (!clk->num_parents)
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox