u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Giulio Benetti <giulio.benetti@benettiengineering.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2] clk: fix clk_get_rate() documentation
Date: Sun, 14 Feb 2021 04:17:22 +0100	[thread overview]
Message-ID: <CCD849BE-E15E-4787-BC4E-F23E2605446B@benettiengineering.com> (raw)
In-Reply-To: <CAJFTR8TTy1_K-Lu6_GOeYhXh-asPqs2jAo07_mmVUvy0kUgJ7A@mail.gmail.com>

Hi Jesse,

> Il giorno 14 feb 2021, alle ore 03:58, Jesse T <mr.bossman075@gmail.com> 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.

> 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.

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). 

> 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

> 
>> On Sat, Feb 13, 2021 at 9:17 PM Giulio Benetti <giulio.benetti@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@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
>> 

  reply	other threads:[~2021-02-14  3:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 17:37 [PATCH] clk: fix clk_get_rate() documentation Giulio Benetti
2021-02-12 23:25 ` Sean Anderson
2021-02-13  1:17   ` Giulio Benetti
2021-02-13  4:17     ` Simon Glass
2021-02-13  8:47       ` Giulio Benetti
2021-02-13 18:24         ` Simon Glass
2021-02-14  2:05           ` Giulio Benetti
2021-02-14  2:17           ` [PATCH v2] " Giulio Benetti
2021-02-14  2:58             ` Jesse T
2021-02-14  3:17               ` Giulio Benetti [this message]
2021-02-14  3:49                 ` Jesse T
2021-02-22 19:13                   ` Heinrich Schuchardt
2021-02-23  0:25                     ` Giulio Benetti
2021-04-04 18:56                       ` Giulio Benetti
2021-11-24  4:01             ` Sean Anderson
2021-12-15 19:05             ` Sean Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CCD849BE-E15E-4787-BC4E-F23E2605446B@benettiengineering.com \
    --to=giulio.benetti@benettiengineering.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).