clk: fix clk_get_rate() always return ulong
RFC PATCH v2 1/1 clk: fix clk_get_rate() always return ulong
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.
--- drivers/clk/clk-uclass.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/clk/clk-uclass.c +2 -6
@@ -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)
Signature · 1 line
2.37.2
Hi Julien,
Quoted 8 lines · Julien Masson
According to
clk_opsstruct definition, the callbackget_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().
Quoted 7 lines
log_rethas also been removed since it use anintin the macro definition.Signed-off-by Julien Masson <[email protected]>--- drivers/clk/clk-uclass.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
I would prefer to create a new log_rete() to handle this, with a long argument and return value. But this is OK, I suppose.
Quoted 28 lines
drivers/clk/clk-uclass.c +2
-7@@ -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) --
Quoted 2 lines
2.37.2
Regards,
Simon
Hi Simon,
Quoted 14 lines · Simon Glass
Hi Julien,
Quoted 11 lines · Julien Masson
According to
clk_opsstruct definition, the callbackget_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_rethas also been removed since it use anintin the macro definition.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Julien Masson <[email protected]>---
drivers/clk/clk-uclass.c| 8 ++------1 file changed, 2 insertions(+), 6 deletions(-)Reviewed-by Simon Glass <[email protected]>
Thanks for the review, I appreciate it.
Quoted 3 lines
I would prefer to create a new
log_rete()to handle this, with a long argument and return value. But this is OK, I suppose.
Yes and I guess that could be used in other functions in clk-uclass.c
Quoted 34 lines
Quoted 29 lines
drivers/clk/clk-uclass.c +2
-7@@ -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) --Quoted 2 lines
2.37.2
Regards,
Simon
Signature · 1 line
Julien Masson
Quoted 31 lines · Julien Masson
According to
clk_opsstruct definition, the callbackget_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_rethas also been removed since it use anintin the macro definition.Signed-off-by Julien Masson <[email protected]>--- drivers/clk/clk-uclass.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/clk/clk-uclass.c +1
-1@@ -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 ;
drivers/clk/clk-uclass.c ulong clk_get_rate(struct clk *clk) · line 485
Quoted 10 lines
drivers/clk/clk-uclass.c +1
-5- 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)