Received: by 10.213.65.68 with SMTP id h4csp240172imn; Fri, 23 Mar 2018 03:41:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELtTRctCqUQtTYEktWXUYs/6iaFuSFbVISLQS3X0KMO3P8Mm76qoBiZzVHgqEG7ohT4ppyl/ X-Received: by 10.99.60.89 with SMTP id i25mr3008418pgn.208.1521801663611; Fri, 23 Mar 2018 03:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521801663; cv=none; d=google.com; s=arc-20160816; b=Ow/04HQog0YkWLGgKO+k2UM28iLhz+2U1cbymy4vjJRs8sRPvPQ9E/9FcucF91u4XW G1iaJyMu5/qXuex8tM+xf2VtU2sqjeQmYT+6jbIFIAUrt9wQXRE6emKMhEdn2EA7DTJQ OIv71rMWEv4INqvAb1NGlj9ITcFYq+hmNfks/Vvvh2mGk5KThUq+AsxAjEwlokHaEk/0 6sWYGM0FOHmtNQLXeGtd+09N1TBPGgbCXVZgJuQiNCqpW2tEo1G+bK/rA6IoPk9ByRIk bntWLal12DxHhHXNLt02OEvbfGZWJqSI4VNjcqfeVPD8TxwDQ50o6sCpskQ6bSi+F403 lZIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=PYVUaXfsa+E8NqnxzTygsbni5fIU2YvIMkWQu9vFUYg=; b=PCgDKUjlndIq1Qdw8CR88+gZkYUhCeHi8uyFVUqq+FrF3I/8Iva9nnSupawGna7Ahs DjUU3nLFbeNkTpuaO5hEmgvAfPKozxu65XvI6sc1MV1yGim+PhHlLLWJwqdfiXONZN28 DSMmtDoPauC8AX/ulamjJRB8bMVEip4JRraMdvjuTptx+oP+S2CM6NDwteUmzPf1PhJq EYJe7vErnj7gKeikKa9NtJuhmC1a64T3jtxa5PsS4ZSXNk+beN01frQ+nSwcGPJPA/MH kqdiCY+0MVlKY3A8PUDBBuvhMM+tWUiDUNpVpC07L+UvvYx6IciMjOPdikrBtXq9wwf+ gF/A== ARC-Authentication-Results: i=1; mx.google.com; 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 s9si5832560pgc.202.2018.03.23.03.40.49; Fri, 23 Mar 2018 03:41:03 -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; 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 S933709AbeCWKQv (ORCPT + 99 others); Fri, 23 Mar 2018 06:16:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46842 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933465AbeCWKQs (ORCPT ); Fri, 23 Mar 2018 06:16:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 24768D09; Fri, 23 Mar 2018 10:16:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moritz Fischer , Alexandre Belloni , Sasha Levin Subject: [PATCH 4.4 70/97] rtc: ds1374: wdt: Fix issue with timeout scaling from secs to wdt ticks Date: Fri, 23 Mar 2018 10:54:57 +0100 Message-Id: <20180323094201.536829633@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Moritz Fischer [ Upstream commit 453d0744f6c6ca3f9749b8c57c2e85b5b9f52514 ] The issue is that the internal counter that triggers the watchdog reset is actually running at 4096 Hz instead of 1Hz, therefore the value given by userland (in sec) needs to be multiplied by 4096 to get the correct behavior. Fixes: 920f91e50c5b ("drivers/rtc/rtc-ds1374.c: add watchdog support") Signed-off-by: Moritz Fischer Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-ds1374.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c @@ -527,6 +527,10 @@ static long ds1374_wdt_ioctl(struct file if (get_user(new_margin, (int __user *)arg)) return -EFAULT; + /* the hardware's tick rate is 4096 Hz, so + * the counter value needs to be scaled accordingly + */ + new_margin <<= 12; if (new_margin < 1 || new_margin > 16777216) return -EINVAL; @@ -535,7 +539,8 @@ static long ds1374_wdt_ioctl(struct file ds1374_wdt_ping(); /* fallthrough */ case WDIOC_GETTIMEOUT: - return put_user(wdt_margin, (int __user *)arg); + /* when returning ... inverse is true */ + return put_user((wdt_margin >> 12), (int __user *)arg); case WDIOC_SETOPTIONS: if (copy_from_user(&options, (int __user *)arg, sizeof(int))) return -EFAULT;