[PATCH v2] clk: fix clk_get_rate() documentation

Jesse T mr.bossman075 at gmail.com
Sun Feb 14 03:58:09 CET 2021


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.

On Sat, Feb 13, 2021 at 9:17 PM Giulio Benetti <
giulio.benetti at benettiengineering.com> wrote:

> 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 <giulio.benetti at benettiengineering.com>
> ---
> 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(-)
>
> diff --git a/include/clk.h b/include/clk.h
> index ca6b85fa6f..5a8c7244d0 100644
> --- a/include/clk.h
> +++ b/include/clk.h
> @@ -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);
>
> --
> 2.25.1
>
>


More information about the U-Boot mailing list