From patchwork Wed Sep 9 21:04:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1361063 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=a4n24Rjl; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BmvfT6531z9sTd for ; Thu, 10 Sep 2020 07:04:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF59F822C3; Wed, 9 Sep 2020 23:04:33 +0200 (CEST) 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="a4n24Rjl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 871F982281; Wed, 9 Sep 2020 23:04:31 +0200 (CEST) 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,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) (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 09ACF82189 for ; Wed, 9 Sep 2020 23:04:29 +0200 (CEST) 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-qk1-x744.google.com with SMTP id p4so3922283qkf.0 for ; Wed, 09 Sep 2020 14:04:28 -0700 (PDT) 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=gugqOKvL77/UgqQL7jvmQTKiUep2DsuKw9LSkJAmgKU=; b=a4n24RjlqZAALUGXO2we/WlrvwsotKCq/w5ORYS5BWA1yShqmSRZsgFnMUYGfYzIC4 28IJRE3y3loB5Qhsd5QvdMItMbjw2n4CGu6SkBMA4TTVhKbIDDs4NEkPA3Otm1xYhzQz YlbLXFTnIgEcGWLq4OOwquQD3nNurpAUQv/C4mmmwq81aOnYDVp1Zat2ESGZDmz7tYcG KfK/vL0WWjJFW1trQ8sWC6b0u3c639XLFF0cGvkb0lQ912RbjJMdX6KKwau3iu2s4OSi 4vCbpMTU5WcoltKTuMpsZqSzxQtzZHWFECwwbTf8G1slN2+Ew53idPM4G2fVCLyRFO/i QknQ== 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=gugqOKvL77/UgqQL7jvmQTKiUep2DsuKw9LSkJAmgKU=; b=EDOGYsJlFtVRLlkTudYnhr2Sjprq3JpFvDLGrT7oToLEAGW1A2VuPkjWS/2I9Gjzp4 h2L8OfftxgJmMfrj/jbtvA3u9WmDR0T2c/I4EX9unEDa6XdPk842YpP0jXp4t5Lbtqqz XL8UQiLeDMfOwz6xV5I4FjP1fvf0ge77cBBxlFexZn9AsWCjtb38wxfVGrefvr5D6pab zAVBDfofWseS8jN3tGDIPA/cQX2OwVQUGhEtEM5tY1iUZlrC6YccV5lpdzuj3WbbRmFa z5wPYxo1qh0yIySa/ee4rQXY7oi0681oeoP1B7uXcsvi7KwdgWopEjrC+piwWBE0qrF8 3fxQ== X-Gm-Message-State: AOAM5300vBIxOZTaAHUxyM+NpyIpIlCjDNI5dwBcu26eO6/9mkTwDmbP zGJjC4n/k2CCpFo4/dsTGvNhG+M+SbDHEE9g X-Google-Smtp-Source: ABdhPJyn4bF++vCWjN5CtBeB1Q64uOYGippijq5gV5YHJ7dFHooxnUcdSrEXgWiQtJsvOdhVNxRFuQ== X-Received: by 2002:a37:62c4:: with SMTP id w187mr5101035qkb.102.1599685467812; Wed, 09 Sep 2020 14:04:27 -0700 (PDT) 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 c40sm4664096qtb.72.2020.09.09.14.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 14:04:27 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Bin Meng , Marek Vasut , Jagan Teki , Simon Glass , Heinrich Schuchardt , Sean Anderson Subject: [PATCH v4 1/7] wdt: dw: Switch to using fls for log2 Date: Wed, 9 Sep 2020 17:04:14 -0400 Message-Id: <20200909210420.243190-2-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909210420.243190-1-seanga2@gmail.com> References: <20200909210420.243190-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 12f09a7a39..f25c8d9ab3 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);