[PATCH 2/2] clk: propagate error pointers in clk_hw_to_clk and clk_to_clk_hw

Ahmad Fatoum ahmad at a3f.at
Thu Jan 13 22:59:53 PST 2022


This will make porting helpers easier, because it's harder to miss
error checking.

Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
---
 include/linux/clk.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index 481c28871258..ffc1ac8489b0 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -432,12 +432,12 @@ struct clk_hw {
 
 static inline struct clk *clk_hw_to_clk(struct clk_hw *hw)
 {
-	return &hw->clk;
+	return IS_ERR(hw) ? ERR_CAST(hw) : &hw->clk;
 }
 
 static inline struct clk_hw *clk_to_clk_hw(struct clk *clk)
 {
-	return container_of(clk, struct clk_hw, clk);
+	return IS_ERR(clk) ? ERR_CAST(clk) : container_of(clk, struct clk_hw, clk);
 }
 
 struct clk_div_table {
-- 
2.33.0




More information about the barebox mailing list