From patchwork Tue Dec 22 23:58:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1419533 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ZQhO1HYv; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0tc36WPPz9sVj for ; Wed, 23 Dec 2020 10:59:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 093CA827DF; Wed, 23 Dec 2020 00:59:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZQhO1HYv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C5B87827EE; Wed, 23 Dec 2020 00:59:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 253BE826D9 for ; Wed, 23 Dec 2020 00:59:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qv1-xf2b.google.com with SMTP id j18so6833381qvu.3 for ; Tue, 22 Dec 2020 15:59:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=81pC6w0tIct45MUFekcLyo2x2nn9EDkQq8CDLq37FPc=; b=ZQhO1HYvyQPoTSs/0HpljwUNrlOmBGbcj2G/gbX/5sTsoMvCMF0L3JNbuxsUDx3BKA vvGaPyy9elHPrjPc4qS6CMuWTKSl9YdBdYVVp/JJJ12nb3RbtNktv9+ec+GfzhXiqRBM lh8kmGhbBgnJ5nqNnQ5viVjZn2oy4Gz/JXdQzCsf040LWiFElePyyPuJyYiwNdGYrB7l PPkCMZyGevMoRF1Bxs/Vt6cw11qN3dAWqi45yFh6k8/8o9zu9Ws1/dGBcJZoCfHzJBo9 CadA01P2710Ggh3VkCJInyUSiEPSo5sq4xFeeMDiUPwEYhVrQFlj1uKjWU7EundIsY2e j0lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=81pC6w0tIct45MUFekcLyo2x2nn9EDkQq8CDLq37FPc=; b=l1q3uLKo2ddP1CW9Ie2pYI40d315bkKdKeiwmkFyQi57iNFHdr3kzt3RT3vL9pvClz 9OOI44RRKlrERjpRPUJEJuH3OEhYsuOknCuE+GZ5bb5J3tQK+986aTA9o7h+3vVnxRO+ rYU56wK4GKnPr3fRJUhU00cYyBMJOPyzgQMqVnUrGf4Zmfy9ypx0EbRjanK8ibKwkAbt b86iZ3eE8Gxcgl1t3JVejyV8FV+65G8EwkDb7aO4Ozo2ux0Y6xQw9K5JWLgrhVUakSQy ReUZvuZQrtpE/FfqSsghN+lJ29DBSXUKqxJ5u2FEigRCF7sJlZmZ6zOHF0bGbnSxyz28 RNWQ== X-Gm-Message-State: AOAM531FTmJhD5uaAmiLK19Nglr9f8oeMLNTWn48vhRf0cxQraMt2BXp BYFQZF6PPr2okqlCsfsXiA9+YticSeXcUQ== X-Google-Smtp-Source: ABdhPJyD/adtI7bMPhW+euftvdIXSivjc4EKfneDZ7o+5nZJENCRh1AW8HD+MKa4qOdvButnhKr/Ww== X-Received: by 2002:a05:6214:321:: with SMTP id j1mr24761063qvu.32.1608681548945; Tue, 22 Dec 2020 15:59:08 -0800 (PST) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id j29sm13097739qtv.11.2020.12.22.15.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 15:59:08 -0800 (PST) From: Sean Anderson To: u-boot@lists.denx.de Cc: Marek Vasut , Jagan Teki , Heinrich Schuchardt , Simon Glass , Bin Meng , Sean Anderson Subject: [PATCH v5 1/6] wdt: dw: Switch to using fls for log2 Date: Tue, 22 Dec 2020 18:58:58 -0500 Message-Id: <20201222235903.131751-2-seanga2@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201222235903.131751-1-seanga2@gmail.com> References: <20201222235903.131751-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean log_2_n_round_up is only found in arm. fls performs the same job and is generic. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- (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 #include #include -#include #include #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);