Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5358758imm; Tue, 21 Aug 2018 10:20:10 -0700 (PDT) X-Google-Smtp-Source: AA+uWPymbgOablVpv5OGUne3efhabxTl09qQ5ib+QtoWUUrIBokqvh5TbP4OIwQ6TuhKSYAevCY+ X-Received: by 2002:a62:642:: with SMTP id 63-v6mr54000259pfg.42.1534872010541; Tue, 21 Aug 2018 10:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534872010; cv=none; d=google.com; s=arc-20160816; b=buuM2lZnLvT7XFB1VW5lCOpthelfl+tL+GnkWreTz4EbegSGeLpaqj6i+9Wmk2zx4b OaehfwuMaxvYisTeYVxVMtRmomQf6AqHtvKLevWJ2od/QTgM91il/ZydnXXYSzcM55QR cLjVKa5FXBsJoJqhswvtGFq3hiz1I2ImyNoOtP+YmSOQ7OoMm9VFlqq5jOcW6nvexhcf jLPLGIyr0fLaNSqqlrC71HjP9TI2zQEhxTseSu7yX7B3vQ7Xwwr7YlcWpVdFG+JvJZIg JDCEqnU6RPck2h5x7XmbcraFPsETfLtrkh4rt6ZUbKNgfkZxcquervbcV3p5CWWPIq/f qHTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=tBIxg5wGqomJKe9TZsyGLBfl5Hk6jZE8QDCNVIndQ3s=; b=IM1ECkKJhmjiFlVa3xXsLO+GbUxae16eB7lSpLr8ncerzQN2xRjHgD+YehHlgVhLns TgggxtGJQhcyOTNRxMVo5aY7YomdbPT/oB4URnvKkE2O7EAdC9vJRQKR3JZ5kdEkHRgM 0vyzCAc2aQFFkC4VPtsmZnzAU2Yqvh0pfG7V7Jnmg9ottjvRTYcJgKMSLrvwtuU0PQZG poh2uKgYDgi5D83a+4bRPZvBFY1l0ExmGaIlo3pjNwVImjwlsBBP8+Cc2xLhMNMl/se1 Vy1a1eKM5WECjh9KZboonKUgAolmezPEG/KXPHx+H1bO09pK4h7RVAcx4BgzED0lvXF6 GEyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=nC5RlNo3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7-v6si12794534pgm.677.2018.08.21.10.19.55; Tue, 21 Aug 2018 10:20:10 -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=@crapouillou.net header.s=mail header.b=nC5RlNo3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728189AbeHUUiI (ORCPT + 99 others); Tue, 21 Aug 2018 16:38:08 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:58200 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727948AbeHUUiI (ORCPT ); Tue, 21 Aug 2018 16:38:08 -0400 From: Paul Cercueil To: Thomas Gleixner , Daniel Lezcano , Rob Herring , Thierry Reding , Mark Rutland , Ralf Baechle , Paul Burton , Jonathan Corbet Cc: od@zcrc.me, Mathieu Malaterre , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-mips@linux-mips.org, linux-doc@vger.kernel.org, linux-clk@vger.kernel.org, Paul Cercueil Subject: [PATCH v7 10/24] watchdog: jz4740: Avoid starting watchdog in set_timeout Date: Tue, 21 Aug 2018 19:16:21 +0200 Message-Id: <20180821171635.22740-11-paul@crapouillou.net> In-Reply-To: <20180821171635.22740-1-paul@crapouillou.net> References: <20180821171635.22740-1-paul@crapouillou.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1534871826; bh=tBIxg5wGqomJKe9TZsyGLBfl5Hk6jZE8QDCNVIndQ3s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=nC5RlNo3b+tcMvfjXb4jCFGETVw4/9gJboBH04Hel9NQUgAJbSyOYrulpbh/kDJ/yB+pumsX5pxl+e8HmdnEieZ6h20x45YItuUhDl4iq6V3aexBvLH2BBMru9PfwQg428W1nzm1NF3w31VDnYwVYBBb36mvwwF0ciXn3DE4A/g= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously the jz4740_wdt_set_timeout() function was starting the timer unconditionally, even if it was stopped when that function was entered. Now, the timer will be restarted only if it was already running before this function is called. Signed-off-by: Paul Cercueil Reviewed-by: Guenter Roeck --- Notes: v6: New patch v7: No change drivers/watchdog/jz4740_wdt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c index 0f54306aee25..45d9495170e5 100644 --- a/drivers/watchdog/jz4740_wdt.c +++ b/drivers/watchdog/jz4740_wdt.c @@ -64,13 +64,15 @@ static int jz4740_wdt_set_timeout(struct watchdog_device *wdt_dev, { struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev); u16 timeout_value = (u16)(drvdata->clk_rate * new_timeout); + u32 tcer; + regmap_read(drvdata->map, TCU_REG_WDT_TCER, &tcer); regmap_write(drvdata->map, TCU_REG_WDT_TCER, 0); regmap_write(drvdata->map, TCU_REG_WDT_TDR, timeout_value); regmap_write(drvdata->map, TCU_REG_WDT_TCNT, 0); - regmap_write(drvdata->map, TCU_REG_WDT_TCER, TCU_WDT_TCER_TCEN); + regmap_write(drvdata->map, TCU_REG_WDT_TCER, tcer & TCU_WDT_TCER_TCEN); wdt_dev->timeout = new_timeout; return 0; @@ -86,6 +88,7 @@ static int jz4740_wdt_start(struct watchdog_device *wdt_dev) return ret; jz4740_wdt_set_timeout(wdt_dev, wdt_dev->timeout); + regmap_write(drvdata->map, TCU_REG_WDT_TCER, TCU_WDT_TCER_TCEN); return 0; } -- 2.11.0