From patchwork Sat Apr 6 10:17:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg Hofmann X-Patchwork-Id: 10888111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 126DC15AC for ; Sat, 6 Apr 2019 10:23:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1FE528950 for ; Sat, 6 Apr 2019 10:23:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A64E628AFF; Sat, 6 Apr 2019 10:23:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5231B28950 for ; Sat, 6 Apr 2019 10:23:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726232AbfDFKX2 (ORCPT ); Sat, 6 Apr 2019 06:23:28 -0400 Received: from 178.27.4.93.rev.sfr.net ([93.4.27.178]:58880 "EHLO hofmannsweb.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfDFKX2 (ORCPT ); Sat, 6 Apr 2019 06:23:28 -0400 X-Greylist: delayed 342 seconds by postgrey-1.27 at vger.kernel.org; Sat, 06 Apr 2019 06:23:27 EDT Received: from localhost (localhost.localdomain [127.0.0.1]) by hofmannsweb.com (Postfix) with ESMTP id AE04C3107CF; Sat, 6 Apr 2019 12:17:44 +0200 (CEST) Received: from hofmannsweb.com ([127.0.0.1]) by localhost (hofmannsweb.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id yoDAxLpzE8fc; Sat, 6 Apr 2019 12:17:44 +0200 (CEST) Received: from localhost (localhost.localdomain [127.0.0.1]) by hofmannsweb.com (Postfix) with ESMTP id 3CEDE3107C8; Sat, 6 Apr 2019 12:17:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 hofmannsweb.com 3CEDE3107C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hofmannsweb.com; s=5A2CD3FC-E3ED-11E4-B8B6-D3B199B2F681; t=1554545864; bh=TwJD/n2NuxTr6vrYXaZNNEZfOm+dRbOC/GZBmZf+690=; h=Date:From:To:Message-ID:MIME-Version; b=YtB4UU40HJTzFCev7lDvhbygua2pt6hqeHU2DmGebjvaejJYd9tplxr88C1XoPcgk f1ILh2ElzXVeQFAedVOY512h9qk2OWGaSmmZD15TLOjPyhUMxhxCWHRRGiRe06gVGX JDV6jNKsDydC4oKvYZLkLrkjXb/M/S9PIPCU8Ge8= X-Virus-Scanned: amavisd-new at hofmannsweb.com Received: from hofmannsweb.com ([127.0.0.1]) by localhost (hofmannsweb.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Jf4MPbyKa60k; Sat, 6 Apr 2019 12:17:44 +0200 (CEST) Received: from hofmannsweb.com (hofmannsweb.com [192.168.1.10]) by hofmannsweb.com (Postfix) with ESMTP id 22F013107C3; Sat, 6 Apr 2019 12:17:44 +0200 (CEST) Date: Sat, 6 Apr 2019 12:17:43 +0200 (CEST) From: Georg Hofmann To: wim@linux-watchdog.org Cc: linux@roeck-us.net, linux-watchdog@vger.kernel.org Message-ID: <1274287303.1911.1554545863744.JavaMail.zimbra@hofmannsweb.com> Subject: [PATCH] Fix set_timeout for big timeout values MIME-Version: 1.0 X-Originating-IP: [192.168.1.11] X-Mailer: Zimbra 8.8.11_GA_3780 (ZimbraWebClient - FF66 (Mac)/8.8.11_GA_3787) Thread-Index: hpDURopEjPpd12ToB1/fo7lp6LEylw== Thread-Topic: Fix set_timeout for big timeout values Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch implements the documented behavior: if max_hw_heartbeat_ms is implemented, the minimum of the set_timeout argument and max_hw_heartbeat_ms should be used. Previously only the first 7 bits were used and the input argument was returned. Signed-off-by: Georg Hofmann --- drivers/watchdog/imx2_wdt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index 2b52514..3c13adc 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -178,9 +178,11 @@ static void __imx2_wdt_set_timeout(struct watchdog_device *wdog, static int imx2_wdt_set_timeout(struct watchdog_device *wdog, unsigned int new_timeout) { - __imx2_wdt_set_timeout(wdog, new_timeout); + unsigned int actual; - wdog->timeout = new_timeout; + actual = min(new_timeout, wdog->max_hw_heartbeat_ms * 1000); + __imx2_wdt_set_timeout(wdog, actual); + wdog->timeout = actual; return 0; }