Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp176075imm; Tue, 22 May 2018 16:25:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoOAwKoKpsVQPOm6dwA0DRKhJ9yW6s/3znNWfoJ4uu/XiMQj/EdFbYHVVKU4Rr8jexIVLfF X-Received: by 2002:a62:dfcd:: with SMTP id d74-v6mr463412pfl.114.1527031502560; Tue, 22 May 2018 16:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527031502; cv=none; d=google.com; s=arc-20160816; b=Oz5BeLU6I63KBuFa8bWrTT32p2VmdvCDs7QZkAJB8XBP96PwnqZYQyvWAUQmbczTe4 IX/QCyhPxtNId9DfE6aUL7l7bxuNmcMYpU5BSeDqim4GNvLzjuSE9k/phlmYrmrRU/sc Zt7TOqHUwgcrnowDKg6vvAxNtuWltV7xZId+nOM69K4N4oyQKcIva/ch8yyNQCjbUZil p+gU7DZ2ZaFL1MAnk7UELDD+jRTVBz9/8IVWOqv1Moniv2c2zERZDsLPr1USgBE5dQhp 59DtMvkl0J+pbqGvmrnAv2KhP5jBXWLJzxZRv4SXwg1fcQGLSx/zXSoiTIyaMY8yqYCZ AwOQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=qn1Gamf+Hgpq6Lhx193bCz3+wpG49NuhvmUsRWyglKI=; b=X/gPfZHwed3kXtxNgqIHmbrYWpnmjPVy5VJT+arLZYCioSLBcftVnpaCsDwnIoanfB JrZ2Vqylea5L3kg3dHVjH3dNW51/y6HA/VwSyphM777Gvmt/286syLncGS/EO/8hx0vq Q1x2ZJVgGqKhFNnCaVRSY3FP7y2djJatSqjIa9X8ToZVLSfgvKar1+pAeFn1pkG6i2tl OSB9EQxntVIqIgWjmK/EMBJo0TLr3BkMW79h0UjF8RjheMHnvzGw6sjkIDiKp8Ri3DcE pcXnjvU1g93H6oNPM9wQ1U+r9YcRuIpBKbPch03+solrTqWCwwjP4DhWwUL1LwWiujto SQuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=hKgmAdiq; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9-v6si17361937plr.144.2018.05.22.16.24.47; Tue, 22 May 2018 16:25:02 -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=@broadcom.com header.s=google header.b=hKgmAdiq; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753342AbeEVXYd (ORCPT + 99 others); Tue, 22 May 2018 19:24:33 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:44868 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753251AbeEVXYb (ORCPT ); Tue, 22 May 2018 19:24:31 -0400 Received: by mail-qk0-f195.google.com with SMTP id d8-v6so7201919qke.11 for ; Tue, 22 May 2018 16:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qn1Gamf+Hgpq6Lhx193bCz3+wpG49NuhvmUsRWyglKI=; b=hKgmAdiqdsDcvw9hLKs7q6R23IqG48u5VUtGGMqKYCsm4f+eiWerYlsaQ76DFFWuLj ZEmLzEAZO6eKp/ZXWvFubBqpQHlwHPfsYBNHQDx5Vr1lWnfZfD1HyhLAL5J4MJS+hG/g r5KD7RgLnYtczNLgZBhoAaquPwRmLdrmf5H7w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qn1Gamf+Hgpq6Lhx193bCz3+wpG49NuhvmUsRWyglKI=; b=j/YYdHzXo/5souOVMWr/USUerccJw8QO0enYyDtUKUYz6vl44gFZm/ipvdXJmsaUbK ZvvYe7KpmU8aWZ+SeB+RDFZGvD5nn/t7r9M+nAw/rkrLwCx4YgzQULemBnAmtk2c3lWe 58ntL9jk9gTQpE26rTMKYhvwGZwh5e/py7BsFnawkZ3R9+kkeszU4ZzyGuAA9IA3gX0X fG2CXkPVzkiwR33YzWCat0VoTC/hhq0SAtKZNIZEt8GSrUaFeaU5oSOd+YC2xTaq/rkb e9fU4i7B2dRYv5BqLDujIXalmt5nMC7Ci9ZT0Wp+7L4sY65GIzUyV7DIDVG8qPLBuOPV Y47A== X-Gm-Message-State: ALKqPwcc4dKmEAs3B1WBqanLOTq6YftMPk2tdTrMrQFWt+b69JHCMFxt yVyYX/lD9pbHvHWzyrPKJ807iQ== X-Received: by 2002:a37:50c4:: with SMTP id e187-v6mr481209qkb.166.1527031470325; Tue, 22 May 2018 16:24:30 -0700 (PDT) Received: from [10.136.8.248] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id v57-v6sm13910045qtj.47.2018.05.22.16.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 16:24:29 -0700 (PDT) Subject: Re: [PATCH 3/5] watchdog: sp805: set WDOG_HW_RUNNING when appropriate To: Guenter Roeck Cc: Wim Van Sebroeck , Rob Herring , Mark Rutland , Frank Rowand , Catalin Marinas , Will Deacon , linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com References: <1527014840-21236-1-git-send-email-ray.jui@broadcom.com> <1527014840-21236-4-git-send-email-ray.jui@broadcom.com> <20180522205457.GA16363@roeck-us.net> From: Ray Jui Message-ID: <0d92b9e9-a3d1-6e91-8371-b5ed3a83e399@broadcom.com> Date: Tue, 22 May 2018 16:24:25 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180522205457.GA16363@roeck-us.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guenter, On 5/22/2018 1:54 PM, Guenter Roeck wrote: > On Tue, May 22, 2018 at 11:47:18AM -0700, Ray Jui wrote: >> If the watchdog hardware is already enabled during the boot process, >> when the Linux watchdog driver loads, it should reset the watchdog and >> tell the watchdog framework. As a result, ping can be generated from >> the watchdog framework, until the userspace watchdog daemon takes over >> control >> >> Signed-off-by: Ray Jui >> Reviewed-by: Vladimir Olovyannikov >> Reviewed-by: Scott Branden >> --- >> drivers/watchdog/sp805_wdt.c | 22 ++++++++++++++++++++++ >> 1 file changed, 22 insertions(+) >> >> diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c >> index 1484609..408ffbe 100644 >> --- a/drivers/watchdog/sp805_wdt.c >> +++ b/drivers/watchdog/sp805_wdt.c >> @@ -42,6 +42,7 @@ >> /* control register masks */ >> #define INT_ENABLE (1 << 0) >> #define RESET_ENABLE (1 << 1) >> + #define ENABLE_MASK (INT_ENABLE | RESET_ENABLE) >> #define WDTINTCLR 0x00C >> #define WDTRIS 0x010 >> #define WDTMIS 0x014 >> @@ -74,6 +75,18 @@ module_param(nowayout, bool, 0); >> MODULE_PARM_DESC(nowayout, >> "Set to 1 to keep watchdog running after device release"); >> >> +/* returns true if wdt is running; otherwise returns false */ >> +static bool wdt_is_running(struct watchdog_device *wdd) >> +{ >> + struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); >> + >> + if ((readl_relaxed(wdt->base + WDTCONTROL) & ENABLE_MASK) == >> + ENABLE_MASK) >> + return true; >> + else >> + return false; > > return !!(readl_relaxed(wdt->base + WDTCONTROL) & ENABLE_MASK)); > Note ENABLE_MASK contains two bits (INT_ENABLE and RESET_ENABLE); therefore, a simple !!(expression) would not work? That is, the masked result needs to be compared against the mask again to ensure both bits are set, right? Thanks, Ray