From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v5 1/6] wdt: dw: Switch to using fls for log2
Date: Tue, 22 Dec 2020 18:58:58 -0500 [thread overview]
Message-ID: <20201222235903.131751-2-seanga2@gmail.com> (raw)
In-Reply-To: <20201222235903.131751-1-seanga2@gmail.com>
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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
(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(-)
diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c
index 7caa6c550c..c0f43785a9 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.29.2
next prev parent reply other threads:[~2020-12-22 23:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-22 23:58 [PATCH v5 0/6] wdt: Add support for watchdogs on Kendryte K210 Sean Anderson
2020-12-22 23:58 ` Sean Anderson [this message]
2020-12-22 23:58 ` [PATCH v5 2/6] wdt: dw: Switch to if(CONFIG()) instead of using #if Sean Anderson
2020-12-22 23:59 ` [PATCH v5 3/6] wdt: dw: Enable the clock before using it Sean Anderson
2020-12-22 23:59 ` [PATCH v5 4/6] wdt: dw: Free the clock on error Sean Anderson
2020-12-22 23:59 ` [PATCH v5 5/6] riscv: Add watchdog bindings for the k210 Sean Anderson
2020-12-22 23:59 ` [PATCH v5 6/6] riscv: Enable watchdog " Sean Anderson
2021-03-03 11:08 ` Leo Liang
2021-01-13 6:13 ` [PATCH v5 0/6] wdt: Add support for watchdogs on Kendryte K210 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=20201222235903.131751-2-seanga2@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.