Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1146084imm; Wed, 1 Aug 2018 10:57:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdgWG4aKtbuyu7pBtHEmC08JZjxdBxPuv4hXhhSW/oENNimsPrY6uEpAClnMP0p8aYjCu2c X-Received: by 2002:a17:902:22e:: with SMTP id 43-v6mr19866594plc.118.1533146264586; Wed, 01 Aug 2018 10:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146264; cv=none; d=google.com; s=arc-20160816; b=wuQVsxBvUu1AkU0wiD/rFnS6zJLu+Nv9F2+Ep7toop1ifWsMsdq3XiDj24KoC/G8oa dm9p5Z0Rr21Ax4wacd+LwqdOlYGb/d0HewFx/2c1RuAt/Ro9GGIy1p9DCg1h+qDkr8cU pecJL8DKuCjVJEJvKZW7JFXNCFnUBxxtLgSgjnzS1tDmvsR4RckBCBVhjqRm9so7GUEr 2bKGEUrYwOk7lXQg0hVQJlhApA3qOqv7wVipvX3Zxz5ay1MHXRChAqv75ZSl9ztZDXqH nR1L3Ek3Adl9L0q6FBeTJOkn/ri2Pmxb0RWX8jzTvJHhEbA3evxXYoM0n7Z7LYbNnQI7 suKQ== 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=owGEQ7Nik9yv/lDhPDAVQTAFRqQHLrDobb4ZbA3bZF0=; b=tfaf/Y8xuVdGMFiPWR0NiY1EUBdYG/zfMVBCbeI6nyjZppdUmJDp6KOr9lpmqUdx1n ELXoztzCOmRGC1ScAYpTHltqm5fF5ycCRVpoYmqCy3GgF+Nyv6l6TIenrRlK1aEk2IFh fLPUWh0MVAHe3SKvB4eydhZfwL3qYO6wc2OnAP1M+Df39CWTGxEeiMXJ37RdtVp7rK+z NGd/LIUzqFHvVWwjKzrRiZzOQf7Gtb7gagA2aUPJGlP2rJGelHaI9Afn5j0Df8Bp0KcE 0Dj1+L+cxUupsPvZIe2kSdhbO0P8hSZrDQlMC/n0vgQLUHgkWOfdCt2qvSZ941Gi13PJ bH2A== 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 u19-v6si15967510pgk.100.2018.08.01.10.57.30; Wed, 01 Aug 2018 10:57:44 -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 S1729781AbeHATmq (ORCPT + 99 others); Wed, 1 Aug 2018 15:42:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50270 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405948AbeHATIk (ORCPT ); Wed, 1 Aug 2018 15:08:40 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8D8811367; Wed, 1 Aug 2018 17:13:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marco Felsch , Guenter Roeck , Wim Van Sebroeck , Sasha Levin Subject: [PATCH 4.14 040/246] watchdog: da9063: Fix updating timeout value Date: Wed, 1 Aug 2018 18:49:10 +0200 Message-Id: <20180801165013.601287770@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marco Felsch [ Upstream commit 44ee54aabfdb3b35866ed909bde3ab01e9679385 ] The DA9063 watchdog has only one register field to store the timeout value and to enable the watchdog. The watchdog gets enabled if the value is not zero. There is no issue if the watchdog is already running but it leads into problems if the watchdog is disabled. If the watchdog is disabled and only the timeout value should be prepared the watchdog gets enabled too. Add a check to get the current watchdog state and update the watchdog timeout value on hw-side only if the watchdog is already active. Fixes: 5e9c16e37608 ("watchdog: Add DA9063 PMIC watchdog driver.") Signed-off-by: Marco Felsch Reviewed-by: Guenter Roeck Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/watchdog/da9063_wdt.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) --- a/drivers/watchdog/da9063_wdt.c +++ b/drivers/watchdog/da9063_wdt.c @@ -102,10 +102,23 @@ static int da9063_wdt_set_timeout(struct { struct da9063 *da9063 = watchdog_get_drvdata(wdd); unsigned int selector; - int ret; + int ret = 0; selector = da9063_wdt_timeout_to_sel(timeout); - ret = _da9063_wdt_set_timeout(da9063, selector); + + /* + * There are two cases when a set_timeout() will be called: + * 1. The watchdog is off and someone wants to set the timeout for the + * further use. + * 2. The watchdog is already running and a new timeout value should be + * set. + * + * The watchdog can't store a timeout value not equal zero without + * enabling the watchdog, so the timeout must be buffered by the driver. + */ + if (watchdog_active(wdd)) + ret = _da9063_wdt_set_timeout(da9063, selector); + if (ret) dev_err(da9063->dev, "Failed to set watchdog timeout (err = %d)\n", ret);