public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 1/7] wdt: dw: Switch to using fls for log2
@ 2020-08-07 15:03 Sean Anderson
  2020-08-07 15:03 ` [PATCH v2 2/7] wdt: dw: Switch to if(CONFIG()) instead of using #if Sean Anderson
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Sean Anderson @ 2020-08-07 15:03 UTC (permalink / raw)
  To: u-boot

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

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

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);
-- 
2.28.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-08-12  3:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-07 15:03 [PATCH v2 1/7] wdt: dw: Switch to using fls for log2 Sean Anderson
2020-08-07 15:03 ` [PATCH v2 2/7] wdt: dw: Switch to if(CONFIG()) instead of using #if Sean Anderson
2020-08-07 15:03 ` [PATCH v2 3/7] wdt: dw: Fix clock rate being off by 1000 Sean Anderson
2020-08-07 15:03 ` [PATCH v2 4/7] wdt: dw: Enable the clock before using it Sean Anderson
2020-08-07 15:03 ` [PATCH v2 5/7] wdt: dw: Free the clock on error Sean Anderson
2020-08-07 15:03 ` [PATCH v2 6/7] riscv: Add watchdog bindings for the k210 Sean Anderson
     [not found]   ` <752D002CFF5D0F4FA35C0100F1D73F3FA4734090@ATCPCS16.andestech.com>
2020-08-12  3:30     ` Rick Chen
2020-08-07 15:03 ` [PATCH v2 7/7] riscv: Enable watchdog " Sean Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox