Skip to contentSkip to conversation

drivers: clk: Adjust temp var data type to properly match that of struct clk_ops

PATCH Applied Nathan Barrett-Morrison 2 participants 3 messages May 15, 2023 – Nov 1, 2023 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: clk: Adjust temp var data type to properly match that of struct clk_ops

In commit 5c5992cb90cf ("clk: Add debugging for return values"), a temporary storage variable was added around the ops->get_rate() call inside clk_get_rate(), so that the result could be passed through log_ret.

This temporary variable was declared as an int, yet when we look in struct clk_ops, we can see this needs to be a ulong:
ulong (*get_rate)(struct clk *clk);

This was resulting in a signed to unsigned casting error on our builds, where a clock value of 0xABCDABCD was being incorrectly cast to 0xFFFFFFFFABCDABCD.

---
 drivers/clk/clk-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-uclass.c +1 -1
index dc3e9d6a26..4e3e3b8537 100644
@@ -471,7 +471,7 @@ void clk_free(struct clk *clk)
 ulong clk_get_rate(struct clk *clk)
 {
 	const struct clk_ops *ops;
-	int ret;
+	ulong ret;
 
 	debug("%s(clk=%p)\n", __func__, clk);
 	if (!clk_valid(clk))
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Nathan Barrett-Morrison

In commit 5c5992cb90cf ("clk: Add debugging for return values"), a temporary storage variable was added around the ops->get_rate() call inside clk_get_rate(), so that the result could be passed through log_ret.

This temporary variable was declared as an int, yet when we look in struct clk_ops, we can see this needs to be a ulong:
ulong (*get_rate)(struct clk *clk);

This was resulting in a signed to unsigned casting error on our builds, where a clock value of 0xABCDABCD was being incorrectly cast to 0xFFFFFFFFABCDABCD.

---
  drivers/clk/clk-uclass.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-uclass.c +0 -0
index dc3e9d6a26..4e3e3b8537 100644

drivers/clk/clk-uclass.c void clk_free(struct clk *clk) · line 477

Quoted 8 lines
drivers/clk/clk-uclass.c +1 -1
@@ -471,7 +471,7 @@ void clk_free(struct clk *clk)
  ulong clk_get_rate(struct clk *clk)
  {
  	const struct clk_ops *ops;
-	int ret;
+	ulong ret;
 
  	debug("%s(clk=%p)\n", __func__, clk);
  	if (!clk_valid(clk))
#2 lore raw
In reply to Nathan Barrett-Morrison
Quoted 10 lines · Nathan Barrett-Morrison

In commit 5c5992cb90cf ("clk: Add debugging for return values"), a temporary storage variable was added around the ops->get_rate() call inside clk_get_rate(), so that the result could be passed through log_ret.

This temporary variable was declared as an int, yet when we look in struct clk_ops, we can see this needs to be a ulong:
ulong (*get_rate)(struct clk *clk);

[...]

Applied, thanks!

[1/1] drivers: clk: Adjust temp var data type to properly match that of struct clk_ops

      commit: aed6480fadede2b87103568aaa117a423a1c3fdc

Best regards,

Signature · 1 line
Sean Anderson <[email protected]>