public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 1/7] wdt: dw: Switch to using fls for log2
Date: Wed, 5 Aug 2020 18:14:43 -0400	[thread overview]
Message-ID: <83bc5c37-57f8-98cf-6810-e230caee0139@gmail.com> (raw)
In-Reply-To: <f386c156-cda8-3dc2-dea9-81662ae35538@gmx.de>

On 8/5/20 5:06 PM, Heinrich Schuchardt wrote:
> On 8/5/20 9:14 PM, Sean Anderson wrote:
>> log_2_n_round_up is only found in arm. fls performs the same job and is
>> generic.
>>
>> Signed-off-by: Sean Anderson <seanga2@gmail.com>
>> ---
>>
>>  drivers/watchdog/designware_wdt.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c
>> index 12f09a7a39..5684acefd2 100644
>> --- a/drivers/watchdog/designware_wdt.c
>> +++ b/drivers/watchdog/designware_wdt.c
>> @@ -9,7 +9,6 @@
>>  #include <reset.h>
>>  #include <wdt.h>
>>  #include <asm/io.h>
>> -#include <asm/utils.h>
>>  #include <linux/bitops.h>
>>
>>  #define DW_WDT_CR	0x00
>> @@ -35,7 +34,7 @@ static int designware_wdt_settimeout(void __iomem *base, unsigned int clk_khz,
>>  	signed int i;
>>
>>  	/* calculate the timeout range value */
>> -	i = log_2_n_round_up(timeout * clk_khz) - 16;
>> +	i = fls(timeout * clk_khz) - 16;
> 
> The two functions create different results:
> 
> generic_fls(15) = 4, log_2_n_round_up(15) = 4
> generic_fls(16) = 5, log_2_n_round_up(16) = 4
> generic_fls(17) = 5, log_2_n_round_up(17) = 5
> 
> Please, describe the effect of your change in the commit message.

Hm, then perhaps this should be

i = fls(timeout * clk_khz - 1) - 16;

--Sean

      reply	other threads:[~2020-08-05 22:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 19:14 [PATCH 1/7] wdt: dw: Switch to using fls for log2 Sean Anderson
2020-08-05 19:14 ` [PATCH 2/7] wdt: dw: Switch to if(CONFIG()) instead of using #if Sean Anderson
2020-08-05 21:10   ` Heinrich Schuchardt
2020-08-05 19:14 ` [PATCH 3/7] wdt: dw: Fix clock rate being off by 1000 Sean Anderson
2020-08-16  3:39   ` Simon Glass
2020-08-05 19:14 ` [PATCH 4/7] wdt: dw: Enable the clock before using it Sean Anderson
2020-08-16  3:39   ` Simon Glass
2020-08-05 19:14 ` [PATCH 5/7] wdt: dw: Free the clock on error Sean Anderson
2020-08-16  3:39   ` Simon Glass
2020-08-05 19:14 ` [PATCH 6/7] riscv: Add watchdog bindings for the k210 Sean Anderson
2020-08-05 19:14 ` [PATCH 7/7] riscv: Enable watchdog " Sean Anderson
2020-08-05 21:06 ` [PATCH 1/7] wdt: dw: Switch to using fls for log2 Heinrich Schuchardt
2020-08-05 22:14   ` Sean Anderson [this message]

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=83bc5c37-57f8-98cf-6810-e230caee0139@gmail.com \
    --to=seanga2@gmail.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