[RFC PATCH v2] clk: fix clk_get_rate() always return ulong

Julien Masson jmasson at baylibre.com
Mon Aug 29 11:11:37 CEST 2022


According to clk_ops struct definition, the callback `get_rate()`
return current clock rate value as ulong.
`clk_get_rate()` should handle the clock rate returned as ulong also.

Otherwise we may have invalid/truncated clock rate value returned by
`clk_get_rate()`.

`log_ret` has also been removed since it use an `int` in the macro
definition.

Signed-off-by: Julien Masson <jmasson at baylibre.com>
---
 drivers/clk/clk-uclass.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index b89c77bf79..c351fa97d1 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -469,7 +469,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))
@@ -479,11 +479,7 @@ ulong clk_get_rate(struct clk *clk)
 	if (!ops->get_rate)
 		return -ENOSYS;
 
-	ret = ops->get_rate(clk);
-	if (ret)
-		return log_ret(ret);
-
-	return 0;
+	return ops->get_rate(clk);
 }
 
 struct clk *clk_get_parent(struct clk *clk)
-- 
2.37.2



More information about the U-Boot mailing list