diff mbox series

[v3,1/7] wdt: dw: Switch to using fls for log2

Message ID 20200901200758.543851-2-seanga2@gmail.com
State Superseded
Delegated to: Andes
Headers show
Series wdt: Add support for watchdogs on Kendryte K210 | expand

Commit Message

Sean Anderson Sept. 1, 2020, 8:07 p.m. UTC
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>
---

(no changes since v2)

Changes in v2:
- Fix fls being off-by-one when compared to log_2_n_round_up

 drivers/watchdog/designware_wdt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Simon Glass Sept. 7, 2020, 1:43 a.m. UTC | #1
On Tue, 1 Sep 2020 at 14:08, Sean Anderson <seanga2@gmail.com> 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>
> ---
>
> (no changes since v2)
>
> Changes in v2:
> - Fix fls being off-by-one when compared to log_2_n_round_up
>
>  drivers/watchdog/designware_wdt.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c
index 12f09a7a39..f25c8d9ab3 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 - 1) - 16;
 	i = clamp(i, 0, 15);
 
 	writel(i | (i << 4), base + DW_WDT_TORR);