Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp529457imm; Wed, 23 May 2018 00:54:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpsvy4yMJc06Dd5bFsvIpiqP0RpKBb7YnCmYANJvOiCAbut+qiYfm8ELVhntnxPa6VdmKvm X-Received: by 2002:a17:902:5481:: with SMTP id e1-v6mr1826658pli.137.1527062055496; Wed, 23 May 2018 00:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527062055; cv=none; d=google.com; s=arc-20160816; b=tX2p1bcMqVvvnKQslLoXdHgUMBG+eJ/zJ7rfFQsjfU3NHFG5wZvPEcXAWLZlj6cphK y/h+wS3oCVOyLTrkhJDdlmqZZ4jvPCZNK9j4qs2PJC72mEll2ehkXvyRKA0GTV6IC+nl 5GUld8LTGGZcDvOiI16PvABneuLHWytR26N1cA6VUmIFhXX1fP6Sk0TO9P3a7CnP/Bjq F3SOKWpvPZ9YmTGza1H9oVZTqWmJCiSjyRgK+cU7jk2xfYHLYpmtV4u7AhiwxZ9jwTgU 2z3OfeSu3JK/FGIEo8gHy2U5BkMkUIr2S/P5JdR1ICsAAAHCVmGqXa/l36o0KtAV9Zie Cxhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=yUjbzjH0j/PGEYBPweejbDARxTUDI0STYcRxmsWwc1Y=; b=CezTCPnDxBsgEWec9yv+ci/ZlX2s2IYyflGwDNIpbF3cmRO2CpPnTRy3AOMfa178tx VgsCjcochDlRX4iTMeQhJkzBGNLYOHtjY1L3VQxj/xx/VRXaw7QuFYxj5vkhdnZoiMqG /YEeBrDgKVCZfTDL74EVPaxj7Iz4jaQmktfHzCKU4rF0gb+QkGFa4wrCWIyptVqnMX68 BeA67D3AY0bvwrlsWA5bhVc6zAsTU7bgjfVoPvn+mpBm9IgYlgaD74Z1j/zE39fpMe0E azcYe21RrZ0TzzCqFaVQZk7oe0lzkY/Enw3xt92F3FM+qJ6A11LlfYKkwZQWRo9yPs44 jkMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=TU50enT/; 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 t3-v6si17636553plo.554.2018.05.23.00.54.00; Wed, 23 May 2018 00:54:15 -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=TU50enT/; 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 S932096AbeEWHwe (ORCPT + 99 others); Wed, 23 May 2018 03:52:34 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:44144 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753992AbeEWHwc (ORCPT ); Wed, 23 May 2018 03:52:32 -0400 Received: by mail-qt0-f195.google.com with SMTP id d3-v6so26903241qtp.11 for ; Wed, 23 May 2018 00:52:31 -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-transfer-encoding:content-language; bh=yUjbzjH0j/PGEYBPweejbDARxTUDI0STYcRxmsWwc1Y=; b=TU50enT/cH4Nsuozckv8iq9Ektl/NkQ36xNFd3gwMatWCHr2pKwhvt/i+MTAQn1G88 1Sbh5BjrIEN4igEzs8hjMIZFw6sGPCwEjnq6SMeZXkhOnOozZlkieFlmGfYuB91Ig6/Q UaEFj/7qhZ4OMGB+njiM2JI1R7NyWGv+SN5yM= 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-transfer-encoding :content-language; bh=yUjbzjH0j/PGEYBPweejbDARxTUDI0STYcRxmsWwc1Y=; b=T2Z6g0t2aezbYo7AMIQnIt3MrI7gOJlA6sO4RrwjM69zJLMMC6jV4EglFkF1NAkZGr bexQQIXPrUJTZRJ1JpWb+ENfxK9NNu5TmCjFmC0n0UPVqPGH4V2mDsny7DJSzvJtmCLR abpvSXnLRLE99uaws8zngCikr6yXjAiKQ4lmBEdDnfQcvWNU0U9JkiTu5Kpb6Ueb3g9V V+UIKj9/CWf2K/2Rdtr7L00yfyb7RLIDMSLfQzX69mab8LU12ew1sLb9f21hA4o6/4PY uCg2IzaKQJt6wClOPSKp2F96tAMEbq34c5A4sx/o3ZdMpmh0/+p4wy8ARajXfFfY/pUf l4PQ== X-Gm-Message-State: ALKqPwec82JRnSkLxHeGoLjxEhvSc0+AUWLQwnuWjbotvKoqu5vnFYfd 74A5/gBFGTaYIcCzqvFnofeOHM4nS+I= X-Received: by 2002:a0c:b38c:: with SMTP id t12-v6mr1528856qve.21.1527061951451; Wed, 23 May 2018 00:52:31 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id 132-v6sm10889861qke.75.2018.05.23.00.52.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 00:52:30 -0700 (PDT) Subject: Re: [PATCH 3/5] watchdog: sp805: set WDOG_HW_RUNNING when appropriate To: Ray Jui , 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> <0d92b9e9-a3d1-6e91-8371-b5ed3a83e399@broadcom.com> From: Scott Branden Message-ID: <00c121ea-d197-93b8-2f56-bcca963f70fb@broadcom.com> Date: Wed, 23 May 2018 00:52:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <0d92b9e9-a3d1-6e91-8371-b5ed3a83e399@broadcom.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18-05-22 04:24 PM, Ray Jui wrote: > 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? Ray - your original code looks correct to me.  Easier to read and less prone to errors as shown in the attempted translation to a single statement. > > Thanks, > > Ray