Skip to contentSkip to conversation

clk: change clk_get_num_parents into clk_hw_get_num_parents

PATCH Applied Ahmad Fatoum 2 participants 3 messages Jan 14, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 clk: change clk_get_num_parents into clk_hw_get_num_parents

There is no clk_get_num_parents in Linux, but clk_hw_get_num_parents. Our only users uses it with a clk_hw, so adjust the function accordingly.

---
 drivers/clk/at91/clk-generated.c | 2 +-
 include/linux/clk.h              | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/clk/at91/clk-generated.c +1 -1
index 628ff407d91e..e639fb3a1a65 100644
@@ -92,7 +92,7 @@ static int clk_generated_set_parent(struct clk_hw *hw, u8 index)
 {
 	struct clk_generated *gck = to_clk_generated(hw);
 
-	if (index >= clk_get_num_parents(clk_hw_to_clk(hw)))
+	if (index >= clk_hw_get_num_parents(hw))
 		return -EINVAL;
 
 	gck->parent_id = index;
include/linux/clk.h +2 -2
index 6565429a9b9f..481c28871258 100644
@@ -721,9 +721,9 @@ int of_clk_add_provider(struct device_node *np,
 						   void *data),
 			void *data);
 
-static inline unsigned int clk_get_num_parents(const struct clk *hw)
+static inline unsigned int clk_hw_get_num_parents(const struct clk_hw *hw)
 {
-	return hw->num_parents;
+	return hw->clk.num_parents;
 }
 
 #else
Signature · 7 lines
2.33.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

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

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

---
 include/linux/clk.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/clk.h +2 -2
index 481c28871258..ffc1ac8489b0 100644
@@ -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 {
Signature · 7 lines
2.33.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#2 lore raw
In reply to Ahmad Fatoum
Quoted 9 lines · Ahmad Fatoum

There is no clk_get_num_parents in Linux, but clk_hw_get_num_parents. Our only users uses it with a clk_hw, so adjust the function accordingly.

---
 drivers/clk/at91/clk-generated.c | 2 +-
 include/linux/clk.h              | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Applied, thanks

Sascha

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