clk: fix clk_get_rate() documentation
PATCH 1/1 clk: fix clk_get_rate() documentation
clk_get_rate() can't and doesn't return -ve on error, it actually returns 0 on error or a value greater than 0 on success. So let's fix its documentation.
--- include/clk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/clk.h +1 -1
@@ -344,7 +344,7 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by * clk_request/get_by_*(). -* @return clock rate in Hz, or -ve error code. +* @return clock rate in Hz on success, or 0 on error. */ ulong clk_get_rate (struct clk *clk);
Signature · 1 line
2.25.1
PATCH 1/1 clk: fix clk_get_rate() documentation
Quoted 15 lines · Giulio Benetti
clk_get_rate()can't and doesn't return -ve on error, it actually returns 0 on error or a value greater than 0 on success. So let's fix its documentation.Signed-off-by Giulio Benetti <[email protected]>--- include/clk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/clk.h +0
-0
include/clk.h int clk_free(struct clk *clk); · line 350
Quoted 8 lines
include/clk.h +1
-1@@ -344,7 +344,7 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by * clk_request/get_by_*(). -* @return clock rate in Hz, or -ve error code. +* @return clock rate in Hz on success, or 0 on error. */ ulong clk_get_rate (struct clk *clk);
NAK. This function *does* return negative errors (see e.g. drivers/clk/clk-uclass.c). However, it may return 0 if passed an invalid clock (see clk_valid).
--Sean
PATCH 1/1 clk: fix clk_get_rate() documentation
Quoted 20 lines · Sean Anderson
Quoted 19 lines · Giulio Benetti
clk_get_rate()can't and doesn't return -ve on error, it actually returns 0 on error or a value greater than 0 on success. So let's fix its documentation.Signed-off-by Giulio Benetti <[email protected]>--- include/clk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/clk.h +1
-1@@ -344,7 +344,7 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by * clk_request/get_by_*(). -* @return clock rate in Hz, or -ve error code. +* @return clock rate in Hz on success, or 0 on error.
Quoted 8 lines
include/clk.h int clk_free(struct clk *clk); · line 350
Quoted 4 lines
include/clk.h +0
-0*/ ulong clk_get_rate (struct clk *clk);NAK. This function *does* return negative errors (see e.g.
drivers/clk/clk-uclass.c). However, it may return 0 if passed an invalid clock (seeclk_valid).
Oops, I didn't dig enough, sorry. It must pass negative value to signal if get_rate() pointer.
Best regards
Signature · 2 lines
Giulio Benetti Benetti Engineering sas
PATCH 1/1 clk: fix clk_get_rate() documentation
Quoted 11 lines · Giulio Benetti
Quoted 9 lines · Sean Anderson
Quoted 8 lines · Giulio Benetti
clk_get_rate()can't and doesn't return -ve on error, it actually returns 0 on error or a value greater than 0 on success. So let's fix its documentation.Signed-off-by Giulio Benetti <[email protected]>--- include/clk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 1/1 clk: fix clk_get_rate() documentation
Hi Simon, Sean,
Quoted 11 lines
Il giorno 13 feb 2021, alle ore 05:17, Simon Glass <[email protected]> ha scritto:
?On Fri, 12 Feb 2021 at 18:17, Giulio Benetti
Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines · Sean Anderson
Quoted 4 lines · Giulio Benetti
clk_get_rate()can't and doesn't return -ve on error, it actually returns 0 on error or a value greater than 0 on success. So let's fix its documentation.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Giulio Benetti <[email protected]>--- include/clk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Reviewed-by Simon Glass <[email protected]>
Sean has already given me a NAK because this function actually return negative values through a ulong return types. I didn?t check into clk-uclass.c and there if get_rate() pointer is not found then it returns a negative value.
Since it?s a bit ambiguous I?ve tried to find a different approach but nothing that easy came into my mind.
Best regards
Giulio Benetti
PATCH 1/1 clk: fix clk_get_rate() documentation
Hi Giulio,
Quoted 19 lines · Giulio Benetti
Hi Simon, Sean,
Quoted 16 lines
Il giorno 13 feb 2021, alle ore 05:17, Simon Glass <[email protected]> ha scritto:
?On Fri, 12 Feb 2021 at 18:17, Giulio Benetti
Quoted 11 lines · <[email protected]> wrote:
Quoted 11 lines · Sean Anderson
Quoted 8 lines · Giulio Benetti
clk_get_rate()can't and doesn't return -ve on error, it actually returns 0 on error or a value greater than 0 on success. So let's fix its documentation.Signed-off-by Giulio Benetti <[email protected]>--- include/clk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines
Quoted 1 line
Reviewed-by Simon Glass <[email protected]>Sean has already given me a NAK because this function actually return negative values through a ulong return types. I didn?t check into
clk-uclass.cand there ifget_rate()pointer is not found then it returns a negative value.
Yes, wrong email...see below.
Quoted 2 lines
Since it?s a bit ambiguous I?ve tried to find a different approach but nothing that easy came into my mind.
Something like this:
* @return clock rate in Hz, 0 for invalid clock, or -ve error code for other error
You can use
Regards,
Simon
PATCH 1/1 clk: fix clk_get_rate() documentation
Quoted 31 lines · Simon Glass
Hi Giulio,
Quoted 19 lines · Giulio Benetti
Hi Simon, Sean,
Quoted 16 lines
Il giorno 13 feb 2021, alle ore 05:17, Simon Glass <[email protected]> ha scritto:
?On Fri, 12 Feb 2021 at 18:17, Giulio Benetti
Quoted 11 lines · <[email protected]> wrote:
Quoted 11 lines · Sean Anderson
Quoted 8 lines · Giulio Benetti
clk_get_rate()can't and doesn't return -ve on error, it actually returns 0 on error or a value greater than 0 on success. So let's fix its documentation.Signed-off-by Giulio Benetti <[email protected]>--- include/clk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 4 lines
Quoted 1 line
Reviewed-by Simon Glass <[email protected]>Sean has already given me a NAK because this function actually return negative values through a ulong return types. I didn?t check into
clk-uclass.cand there ifget_rate()pointer is not found then it returns a negative value.Yes, wrong email...see below.
Quoted 1 line
Quoted 6 lines
Quoted 1 line
Since it?s a bit ambiguous I?ve tried to find a different approach but nothing that easy came into my mind.
Something like this:
* @return clock rate in Hz, 0 for invalid clock, or -ve error code for other error
That's a good idea Simon, thank you, going to send patch for it soon.
Kind regards
Signature · 2 lines
Giulio Benetti Benetti Engineering sas
PATCH v2 1/1 clk: fix clk_get_rate() documentation
In reply to Simon GlassImprove clk_get_rate() @return documentation that otherwise is a bit ambiguous. At the moment I expect to return 0 as error since the return type is 'ulong', instead the function really returns negative value in case the corresponding function pointer is null and returns 0 if the clock is invalid.
---V1->V2:
* previous comment was wrong, this function returns negative value, so let's improve it's @return documentation as suggested by Simon Glass
--- include/clk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/clk.h +2 -1
@@ -344,7 +344,8 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by * clk_request/get_by_*(). -* @return clock rate in Hz, or -ve error code. +* @return clock rate in Hz on success, 0 for invalid clock, or -ve error code +* for other errors. */ ulong clk_get_rate (struct clk *clk);
Signature · 1 line
2.25.1
PATCH v2 1/1 clk: fix clk_get_rate() documentation
This looks good to me, and helps beginners like me. As for the function itself, i have 2 concerns: If it does return a negative value why is it unsigned, if it is in fact signed that a clock above 2.2Ghz is a negative number. As for the IS_ERR_VALUE macro there still is a chance that it will error if the clock just so happens to be 2^31 through 2^31 + number of err values. Just voicing my concerns i assume as i learn more about uboot, linux,rtos's and different programs there will be minor issues like this.
Quoted 36 lines · Giulio Benetti
Improve
clk_get_rate()@return documentation that otherwise is a bit ambiguous. At the moment I expect to return 0 as error since the return type is 'ulong', instead the function really returns negative value in case the corresponding function pointer is null and returns 0 if the clock is invalid.Signed-off-by Giulio Benetti <[email protected]>---
V1->V2:
* previous comment was wrong, this function returns negative value, so let's
improve it's @return documentation as suggested by Simon Glass--- include/clk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/clk.h +0
-0@@ -344,7 +344,8 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by
* clk_request/get_by_*().
- * @return clock rate in Hz, or -ve error code.
+ * @return clock rate in Hz on success, 0 for invalid clock, or -ve error code
+ * for other errors.
*/
ulongclk_get_rate(struct clk *clk);--
2.25.1
PATCH v2 1/1 clk: fix clk_get_rate() documentation
Hi Jesse,
Quoted 4 lines
Il giorno 14 feb 2021, alle ore 03:58, Jesse T <[email protected]> ha scritto:
?
This looks good to me, and helps beginners like me. As for the function itself, i have 2 concerns: If it does return a negative value why is it unsigned, if it is in fact signed that a clock above 2.2Ghz is a negative number.
I was worried too at first sight but if you try to check negative numbers you see that -1 is 0xFFFFFFFF so in the worst case you only loose 4095 numbers from the maximum, try to check with hex calculator. And that is the trick.
Quoted 1 line
As for the
IS_ERR_VALUEmacro there still is a chance that it will error if the clock just so happens to be 2^31 through 2^31 + number of err values.
This is answered from above and IS_ERR_VALUE is a very contracted macro that basically let you to keep value NOT valid if (0 > value > 4095).
Quoted 1 line
Just voicing my concerns i assume as i learn more about uboot, linux,rtos's and different programs there will be minor issues like this.
Sure, no problem :-)
Giulio
Quoted 34 lines
Quoted 34 lines · Giulio Benetti
Improve
clk_get_rate()@return documentation that otherwise is a bit ambiguous. At the moment I expect to return 0 as error since the return type is 'ulong', instead the function really returns negative value in case the corresponding function pointer is null and returns 0 if the clock is invalid.Signed-off-by Giulio Benetti <[email protected]>---
V1->V2:
* previous comment was wrong, this function returns negative value, so let's improve it's @return documentation as suggested by Simon Glass--- include/clk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/clk.h +2
-1@@ -344,7 +344,8 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by * clk_request/get_by_*(). -* @return clock rate in Hz, or -ve error code. +* @return clock rate in Hz on success, 0 for invalid clock, or -ve error code +* for other errors. */ ulong clk_get_rate (struct clk *clk);Signature · 1 line
2.25.1
PATCH v2 1/1 clk: fix clk_get_rate() documentation
Awesome, thanks! I must have forgotten how twos complement works for a sec...
Quoted 73 lines · Giulio Benetti
Hi Jesse,
Il giorno 14 feb 2021, alle ore 03:58, Jesse T <[email protected]> ha scritto:
?
This looks good to me, and helps beginners like me. As for the function itself, i have 2 concerns: If it does return a negative value why is it unsigned, if it is in fact signed that a clock above 2.2Ghz is a negative number.I was worried too at first sight but if you try to check negative numbers you see that -1 is
0xFFFFFFFFso in the worst case you only loose 4095 numbers from the maximum, try to check with hex calculator. And that is the trick.As for the
IS_ERR_VALUEmacro there still is a chance that it will error if the clock just so happens to be 2^31 through 2^31 + number of err values.This is answered from above and
IS_ERR_VALUEis a very contracted macro that basically let you to keep value NOT valid if (0 > value > 4095).Just voicing my concerns i assume as i learn more about uboot, linux,rtos's and different programs there will be minor issues like this.
Sure, no problem :-)
Giulio
Quoted 36 lines · Giulio Benetti
Improve
clk_get_rate()@return documentation that otherwise is a bit ambiguous. At the moment I expect to return 0 as error since the return type is 'ulong', instead the function really returns negative value in case the corresponding function pointer is null and returns 0 if the clock is invalid.Signed-off-by Giulio Benetti <[email protected]>---
V1->V2:
* previous comment was wrong, this function returns negative value, so let's
improve it's @return documentation as suggested by Simon Glass--- include/clk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/clk.h +0
-0@@ -344,7 +344,8 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by
* clk_request/get_by_*().
- * @return clock rate in Hz, or -ve error code.
+ * @return clock rate in Hz on success, 0 for invalid clock, or -ve error code
+ * for other errors.
*/
ulongclk_get_rate(struct clk *clk);--
2.25.1
PATCH v2 1/1 clk: fix clk_get_rate() documentation
Quoted 75 lines · Jesse T
Awesome, thanks! I must have forgotten how twos complement works for a sec...
Quoted 69 lines · Giulio Benetti
Hi Jesse,
Il giorno 14 feb 2021, alle ore 03:58, Jesse T <[email protected]> ha scritto:
?
This looks good to me, and helps beginners like me. As for the function itself, i have 2 concerns: If it does return a negative value why is it unsigned, if it is in fact signed that a clock above 2.2Ghz is a negative number.I was worried too at first sight but if you try to check negative numbers you see that -1 is
0xFFFFFFFFso in the worst case you only loose 4095 numbers from the maximum, try to check with hex calculator. And that is the trick.As for the
IS_ERR_VALUEmacro there still is a chance that it will error if the clock just so happens to be 2^31 through 2^31 + number of err values.This is answered from above and
IS_ERR_VALUEis a very contracted macro that basically let you to keep value NOT valid if (0 > value > 4095).Just voicing my concerns i assume as i learn more about uboot, linux,rtos's and different programs there will be minor issues like this.
Sure, no problem :-)
Giulio
Quoted 32 lines · Giulio Benetti
Improve
clk_get_rate()@return documentation that otherwise is a bit ambiguous. At the moment I expect to return 0 as error since the return type is 'ulong', instead the function really returns negative value in case the corresponding function pointer is null and returns 0 if the clock is invalid.Signed-off-by Giulio Benetti <[email protected]>---
V1->V2:
* previous comment was wrong, this function returns negative value, so let's
improve it's @return documentation as suggested by Simon Glass--- include/clk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/clk.h +0
-0@@ -344,7 +344,8 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by
* clk_request/get_by_*().
- * @return clock rate in Hz, or -ve error code.
+ * @return clock rate in Hz on success, 0 for invalid clock, or -ve error code
+ * for other errors.
*/
ulongclk_get_rate(struct clk *clk);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
--
2.25.1
Cc: Lukasz Majewski <[email protected]>
Lukasz is maintainer for CLOCK.
PATCH v2 1/1 clk: fix clk_get_rate() documentation
Quoted 76 lines · Heinrich Schuchardt
Quoted 75 lines · Jesse T
Awesome, thanks! I must have forgotten how twos complement works for a sec...
Quoted 69 lines · Giulio Benetti
Hi Jesse,
Il giorno 14 feb 2021, alle ore 03:58, Jesse T <[email protected]> ha scritto:
?
This looks good to me, and helps beginners like me. As for the function itself, i have 2 concerns: If it does return a negative value why is it unsigned, if it is in fact signed that a clock above 2.2Ghz is a negative number.I was worried too at first sight but if you try to check negative numbers you see that -1 is
0xFFFFFFFFso in the worst case you only loose 4095 numbers from the maximum, try to check with hex calculator. And that is the trick.As for the
IS_ERR_VALUEmacro there still is a chance that it will error if the clock just so happens to be 2^31 through 2^31 + number of err values.This is answered from above and
IS_ERR_VALUEis a very contracted macro that basically let you to keep value NOT valid if (0 > value > 4095).Just voicing my concerns i assume as i learn more about uboot, linux,rtos's and different programs there will be minor issues like this.
Sure, no problem :-)
Giulio
Quoted 32 lines · Giulio Benetti
Improve
clk_get_rate()@return documentation that otherwise is a bit ambiguous. At the moment I expect to return 0 as error since the return type is 'ulong', instead the function really returns negative value in case the corresponding function pointer is null and returns 0 if the clock is invalid.Signed-off-by Giulio Benetti <[email protected]>---
V1->V2:
* previous comment was wrong, this function returns negative value, so let's
improve it's @return documentation as suggested by Simon Glass--- include/clk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/clk.h +0
-0@@ -344,7 +344,8 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by
* clk_request/get_by_*().
- * @return clock rate in Hz, or -ve error code.
+ * @return clock rate in Hz on success, 0 for invalid clock, or -ve error code
+ * for other errors.*/ulong
clk_get_rate(struct clk *clk);
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
--
2.25.1Cc: Lukasz Majewski <[email protected]>
Lukasz is maintainer for CLOCK.
Ah thank you that's right. I've missed it because./scripts/get_maintainer.pl didn't list him.
Signature · 2 lines
Giulio Benetti Benetti Engineering sas
PATCH v2 1/1 clk: fix clk_get_rate() documentation
Hi Lukasz,
kindly ping
Best regards
Signature · 2 lines
Giulio Benetti Benetti Engineering sas
Quoted 88 lines · Giulio Benetti
Quoted 76 lines · Heinrich Schuchardt
Quoted 75 lines · Jesse T
Awesome, thanks! I must have forgotten how twos complement works for a sec...
Quoted 69 lines · Giulio Benetti
Hi Jesse,
Il giorno 14 feb 2021, alle ore 03:58, Jesse T <[email protected]> ha scritto:
?
This looks good to me, and helps beginners like me. As for the function itself, i have 2 concerns: If it does return a negative value why is it unsigned, if it is in fact signed that a clock above 2.2Ghz is a negative number.I was worried too at first sight but if you try to check negative numbers you see that -1 is
0xFFFFFFFFso in the worst case you only loose 4095 numbers from the maximum, try to check with hex calculator. And that is the trick.As for the
IS_ERR_VALUEmacro there still is a chance that it will error if the clock just so happens to be 2^31 through 2^31 + number of err values.This is answered from above and
IS_ERR_VALUEis a very contracted macro that basically let you to keep value NOT valid if (0 > value > 4095).Just voicing my concerns i assume as i learn more about uboot, linux,rtos's and different programs there will be minor issues like this.
Sure, no problem :-)
Giulio
Quoted 32 lines · Giulio Benetti
Improve
clk_get_rate()@return documentation that otherwise is a bit ambiguous. At the moment I expect to return 0 as error since the return type is 'ulong', instead the function really returns negative value in case the corresponding function pointer is null and returns 0 if the clock is invalid.Signed-off-by Giulio Benetti <[email protected]>---
V1->V2:
* previous comment was wrong, this function returns negative value, so let's
improve it's @return documentation as suggested by Simon Glass--- include/clk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/clk.h +0
-0@@ -344,7 +344,8 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by
* clk_request/get_by_*().
- * @return clock rate in Hz, or -ve error code.
+ * @return clock rate in Hz on success, 0 for invalid clock, or -ve error code
+ * for other errors.*/ ulong clk_get_rate(struct clk *clk);Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
--
2.25.1Cc: Lukasz Majewski <[email protected]>
Lukasz is maintainer for CLOCK.Ah thank you that's right. I've missed it because
./scripts/get_maintainer.pldidn't list him.
Quoted 21 lines · Giulio Benetti
Improve
clk_get_rate()@return documentation that otherwise is a bit ambiguous. At the moment I expect to return 0 as error since the return type is 'ulong', instead the function really returns negative value in case the corresponding function pointer is null and returns 0 if the clock is invalid.Signed-off-by Giulio Benetti <[email protected]>---
V1->V2:
* previous comment was wrong, this function returns negative value, so let's improve it's @return documentation as suggested by Simon Glass--- include/clk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/clk.h +0
-0
include/clk.h int clk_free(struct clk *clk); · line 351
Quoted 9 lines
include/clk.h +2
-1@@ -344,7 +344,8 @@ int clk_free(struct clk *clk);* * @clk: A clock struct that was previously successfully requested by * clk_request/get_by_*(). -* @return clock rate in Hz, or -ve error code. +* @return clock rate in Hz on success, 0 for invalid clock, or -ve error code +* for other errors. */ ulong clk_get_rate (struct clk *clk);
Sean Anderson
AppliedQuoted 8 lines · Giulio Benetti
Improve
clk_get_rate()@return documentation that otherwise is a bit ambiguous. At the moment I expect to return 0 as error since the return type is 'ulong', instead the function really returns negative value in case the corresponding function pointer is null and returns 0 if the clock is invalid.[...]
Applied, thanks!
[1/1] clk: fix clk_get_rate() documentation
commit: 9e578f6340ba3f4324cd823872afe6eda39857d2
Best regards,
Signature · 1 line
Sean Anderson <[email protected]>