Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1049909ybp; Thu, 17 Oct 2019 07:21:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5mDqrpW1wemSFBO/SEvfFMTNs863sHfFQG3h4fgfJlq/zKDUdIrcdc7aASW5OWJ68bCMU X-Received: by 2002:a17:906:5a98:: with SMTP id l24mr3802690ejq.40.1571322077877; Thu, 17 Oct 2019 07:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571322077; cv=none; d=google.com; s=arc-20160816; b=pH3HGPaMRfzj2EOm8pbUIlwuaH3T/4CLma5CnJGFLmINVR7nZAxixKywO2sUEDU852 2aiQGR81W0//ZozufKAHu+5zea/2YfPkjSrcARNZG5L1Q6D36pfR0W0VWMR55uchcz6Y aaRQpvJkPr3ZHFgx43hVq5kyozyShpZi7CAr0MfxEcK8OdnwqIzjtuCBl0Y/+TL25h8q p1g0f0V93/PImxaE3h/dwWT3mRm4ImgL3pjGY2puYnAcRuGYBIyHcyRI0gtEHhgpBifM LO4YywPSI1vNQTAhdz/9Gf2TflNFthVGLfBoJlUs6F1YPAde4lo5fzRrRAgqnQ/D0ZF4 bXCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GMmlQ673qBrmk558zlo5YLW/IME5gifOjqknjDpJ5ms=; b=WCniCEAsFBcFpEz8z0FiR+feMfDlZt+1TNNeUbnVSyW+OQ8ChKdPGzEQc7jBruWKeh mIALvPw0yB1oMNm8kPq1Yy6FkFzRMWGm4x+DKmGwLl5Q/3lPXUbH58TAJYkeeSotnLJ6 nw2iy9McglGynotI9J3vzP75kRrBKfWDU/9zItx11VCo8YeqnFMB5anb3CADgZwsVw9a cjPmt8vYMcUPPTsUb+3k8o35ZzLii+ZQXdC4uu8aMGjBz1NY1Vh65MzzHwvENhbu/Ltm vNeEO183Tf6Zq4NDiNVBrjOURSJW4u0js2R2+dhlrP6G3GKe7cQaP+zIlEQwIwEJTC7Y UrWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KzW7YiOy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ck7si1417436ejb.250.2019.10.17.07.20.53; Thu, 17 Oct 2019 07:21:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KzW7YiOy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395151AbfJPVzA (ORCPT + 99 others); Wed, 16 Oct 2019 17:55:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:45116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395099AbfJPVy4 (ORCPT ); Wed, 16 Oct 2019 17:54:56 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 54ACB20872; Wed, 16 Oct 2019 21:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571262895; bh=85ImHd+iC/uz5AhcNCsQYGkHH6IrmsgFjvEXApBTSiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KzW7YiOy+XgZFSLcdMXQubH44PIkJDgCkSsOm7shs4sJocwsnIbU/GZRbmmmxaYN1 EjW4UnmbdzzAsJTULHmQV6yFNUBrQWtj6GptMbS1lsLXzjkkgpDgU2t+9GLNoheZtb OxbfF2Hd9/V4gUf1C7vT+FHwHJ3/eBcrOrOjkn+Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rasmus Villemoes , Guenter Roeck , Wim Van Sebroeck Subject: [PATCH 4.9 12/92] watchdog: imx2_wdt: fix min() calculation in imx2_wdt_set_timeout Date: Wed, 16 Oct 2019 14:49:45 -0700 Message-Id: <20191016214808.012529416@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214759.600329427@linuxfoundation.org> References: <20191016214759.600329427@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rasmus Villemoes commit 144783a80cd2cbc45c6ce17db649140b65f203dd upstream. Converting from ms to s requires dividing by 1000, not multiplying. So this is currently taking the smaller of new_timeout and 1.28e8, i.e. effectively new_timeout. The driver knows what it set max_hw_heartbeat_ms to, so use that value instead of doing a division at run-time. FWIW, this can easily be tested by booting into a busybox shell and doing "watchdog -t 5 -T 130 /dev/watchdog" - without this patch, the watchdog fires after 130&127 == 2 seconds. Fixes: b07e228eee69 "watchdog: imx2_wdt: Fix set_timeout for big timeout values" Cc: stable@vger.kernel.org # 5.2 plus anything the above got backported to Signed-off-by: Rasmus Villemoes Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20190812131356.23039-1-linux@rasmusvillemoes.dk Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Greg Kroah-Hartman --- drivers/watchdog/imx2_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -58,7 +58,7 @@ #define IMX2_WDT_WMCR 0x08 /* Misc Register */ -#define IMX2_WDT_MAX_TIME 128 +#define IMX2_WDT_MAX_TIME 128U #define IMX2_WDT_DEFAULT_TIME 60 /* in seconds */ #define WDOG_SEC_TO_COUNT(s) ((s * 2 - 1) << 8) @@ -183,7 +183,7 @@ static int imx2_wdt_set_timeout(struct w { unsigned int actual; - actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000); + actual = min(new_timeout, IMX2_WDT_MAX_TIME); __imx2_wdt_set_timeout(wdog, actual); wdog->timeout = new_timeout; return 0;