Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1410124imm; Tue, 10 Jul 2018 01:02:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfuxTKdfY7gthaX2xjXsHWFY8k1yPlza22fjLMuI2e/TLy1C67x3S/qpUFlWs77lDuYkI6M X-Received: by 2002:a62:5486:: with SMTP id i128-v6mr24302548pfb.166.1531209749041; Tue, 10 Jul 2018 01:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531209749; cv=none; d=google.com; s=arc-20160816; b=X9AJ+4GtBPx0+S2GfWChkSFgnk1vxyYKmiPF/sEXVXyUZ/o7xWKiBQ6TR6APmw0p0e XjWUjJ8aVEI8gZipv3EwmysSul2/NjbaPTf3cItsWv9in0Rq5u3ZUW1OTfkesnt55AMO WIyB0HAgvTVu4XUzB6wSMLR1zi+cHwRpJdpiq+I7MOMPK1AoiHMHBMV/0oSVCPLYholK 4CeSG3i/dQ/CIbCeuYLdHYOsH6SBD0YdPoFOh70jGBhCO9RpZkTsjnaA++5JUoljzsHM CVk+EDuP0LVwWHJelx2jwi2jBSe+wvUpxnq2w4DRHiqTVeJmD7Ss7FM3e/bhADcwSveg qK1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=xBshCbIP9kcPO4YjFvZg6AWSXEnyw/dh8APn7DxB+Cs=; b=NGakhEW4pr/oHlfDA101A8BqzxrA0qXRqCAW/MdOD6bJ2q9FoaNHQTmKj8etSwVoBV MdFmTAWGE9vvlY89vsbXbdLFgN1epIXldyq8/kyn/o2HA9WCvz+iPoLxA7V+UvVTtIlA lLKztqbu9OcJUAHQ0NbfM9YCNGGcYEPyKUsjU/b0/DJfUgKd0wZed1i6/hQz7QWdcvaf EWQn+DwZ6gkY+LcLEWh2CXS/g2K39nedj1zk3d3Gwu2IZTjzqOOy+tq42inyFAoyDjaP vUxRl0Ax2ymIlIlGakKE1cTXHvY0yDrQPb8yuBjcdFhRpr2rlp5OzZKsPJOjxRwMb+m7 F0PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=CLmQ3RpW; 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 t1-v6si15818135plq.280.2018.07.10.01.02.13; Tue, 10 Jul 2018 01:02:29 -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=CLmQ3RpW; 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 S1751217AbeGJIBe (ORCPT + 99 others); Tue, 10 Jul 2018 04:01:34 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:39704 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751103AbeGJIBd (ORCPT ); Tue, 10 Jul 2018 04:01:33 -0400 Received: by mail-oi0-f68.google.com with SMTP id d189-v6so40898371oib.6 for ; Tue, 10 Jul 2018 01:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=xBshCbIP9kcPO4YjFvZg6AWSXEnyw/dh8APn7DxB+Cs=; b=CLmQ3RpW/zMhnPo/Lhh2nDyCNCIY0d+yyrCJNYFbOyO2q+Q8h04i2/Q4ntgLyvJTpX PKWxf6SF+suFROdhIZnxDttPbjeXiIwOaIutEpcs/8+WWWyxLHErxY2cdtM8xWEuEKEZ 2r5rhf6fdCQHdD4vbq3mVeqrONZ4HaGu9tsCM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=xBshCbIP9kcPO4YjFvZg6AWSXEnyw/dh8APn7DxB+Cs=; b=hECEUCsWoEC99vKG33ls+oidScsIhtIJiC7cIAXE7RqbNElUNpG6tK40zJGjOmfqvJ cW5R0xKrZSVu5xR5HvZTZr6/aYecUhuWSVk7icGSBCGa2Ce89s3bXV8gqbFKCZCaA/G4 Joow61Hh4X5bA2U0PD6A5sY+1Bhf+2Kis42kdbRoQyPlXu5JPPz3SZCkZXOXPO0skkMg RkoUITzK3GfsC1VjjBwzkx6xu+/j7B0X7fq7j4WkmMwKVAGVZ6z/JhWBgwzX61UkuYYc YZVvkvlZDjnOgB4LE9ikND6H+k5f1uEz4x4COmEnLFFalwFmJW0PV5+0LjqUfADB5UEE EeAw== X-Gm-Message-State: AOUpUlHw3/QiGNAZtawc9wuehaaDxx27be9GCYQ9QnAQqhALzp76LlfX ApPD/tjY63PhacKr55xRFYJdBT6riqIf+hlO3K6YCQ== X-Received: by 2002:aca:44c5:: with SMTP id r188-v6mr6948731oia.280.1531209692282; Tue, 10 Jul 2018 01:01:32 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:6043:0:0:0:0:0 with HTTP; Tue, 10 Jul 2018 01:01:31 -0700 (PDT) In-Reply-To: References: <1531131569-13727-1-git-send-email-srinath.mannam@broadcom.com> <055f7c8a-c3c9-af3a-d762-a26329270e4d@roeck-us.net> From: Srinath Mannam Date: Tue, 10 Jul 2018 13:31:31 +0530 Message-ID: Subject: Re: [RFC PATCH v2] watchdog: sp805: Add clock-frequency property To: Guenter Roeck Cc: wim@linux-watchdog.org, Ray Jui , Vladimir Olovyannikov , Vikram Prakash , Scott Branden , Sudeep Holla , linux-watchdog@vger.kernel.org, Linux Kernel Mailing List 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 Hi Guenter, I missed your comment about "Clearing wdt->clk is useless." I will remove that line. Regards, Srinath. On Tue, Jul 10, 2018 at 1:27 PM, Srinath Mannam wrote: > Hi Guenter, > > Thank you for your feedback. Please find my answers in lined. > > On Mon, Jul 9, 2018 at 7:15 PM, Guenter Roeck wrote: >> On 07/09/2018 03:19 AM, Srinath Mannam wrote: >>> >>> When using ACPI node, binding clock devices are >>> not available as device tree, So clock-frequency >>> property given in _DSD object of ACPI device is >>> used to calculate Watchdog rate. >>> >>> Signed-off-by: Srinath Mannam >>> --- >>> drivers/watchdog/sp805_wdt.c | 34 ++++++++++++++++++++++++++-------- >>> 1 file changed, 26 insertions(+), 8 deletions(-) >>> >>> diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c >>> index 9849db0..ad5ed64 100644 >>> --- a/drivers/watchdog/sp805_wdt.c >>> +++ b/drivers/watchdog/sp805_wdt.c >>> @@ -11,6 +11,7 @@ >>> * warranty of any kind, whether express or implied. >>> */ >>> +#include >>> #include >>> #include >>> #include >>> @@ -22,6 +23,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> #include >>> #include >>> #include >>> @@ -65,6 +67,7 @@ struct sp805_wdt { >>> spinlock_t lock; >>> void __iomem *base; >>> struct clk *clk; >>> + u64 rate; >>> struct amba_device *adev; >>> unsigned int load_val; >>> }; >>> @@ -80,7 +83,7 @@ static int wdt_setload(struct watchdog_device *wdd, >>> unsigned int timeout) >>> struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); >>> u64 load, rate; >>> - rate = clk_get_rate(wdt->clk); >>> + rate = wdt->rate; >>> /* >>> * sp805 runs counter with given value twice, after the end of >>> first >>> @@ -106,9 +109,7 @@ static int wdt_setload(struct watchdog_device *wdd, >>> unsigned int timeout) >>> static unsigned int wdt_timeleft(struct watchdog_device *wdd) >>> { >>> struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); >>> - u64 load, rate; >>> - >>> - rate = clk_get_rate(wdt->clk); >>> + u64 load; >>> spin_lock(&wdt->lock); >>> load = readl_relaxed(wdt->base + WDTVALUE); >>> @@ -118,7 +119,7 @@ static unsigned int wdt_timeleft(struct >>> watchdog_device *wdd) >>> load += wdt->load_val + 1; >>> spin_unlock(&wdt->lock); >>> - return div_u64(load, rate); >>> + return div_u64(load, wdt->rate); >>> } >>> static int >>> @@ -228,10 +229,27 @@ sp805_wdt_probe(struct amba_device *adev, const >>> struct amba_id *id) >>> if (IS_ERR(wdt->base)) >>> return PTR_ERR(wdt->base); >>> - wdt->clk = devm_clk_get(&adev->dev, NULL); >>> - if (IS_ERR(wdt->clk)) { >>> + if (adev->dev.of_node) { >>> + wdt->clk = devm_clk_get(&adev->dev, NULL); >>> + if (IS_ERR(wdt->clk)) { >>> + ret = PTR_ERR(wdt->clk); >>> + wdt->clk = NULL; >> >> >> Clearing wdt->clk is useless. > > If not, clk_prepare_enable and clk_disable_unprepare functions calls > made in this driver will crash. Sorry I missed your point. I will remove that. > >> >>> + } else >>> + wdt->rate = clk_get_rate(wdt->clk); >> >> >> The else branch should be in { } as well per coding style. > I will add the change. >> >>> + } else if (has_acpi_companion(&adev->dev)) { >>> + /* >>> + * When Driver probe with ACPI device, clock devices >>> + * are not available, so watchdog rate get from >>> + * clock-frequency property given in _DSD object. >>> + */ >>> + device_property_read_u64(&adev->dev, "clock-frequency", >>> + &wdt->rate); >> >> >> Continuation line alignment is off. > I missed it, Thank you, I will make the change. >> >> Still not documented. Maybe that is common for ACPI devices nowadays. >> If so, I'll need at least a pointer to a document or something declaring >> that ACPI devices do not use well documented properties, and a confirmation >> that using such properties is acceptable in the Linux kernel. >> > patches listed below has same approach to add ACPI support. > ex: > 1. commit 515da746983bc6382e380ba8b1ce9345a9550ffe > Author: Naveen Kaje > Date: Tue Oct 11 10:27:56 2016 -0600 > > i2c: qup: add ACPI support > > 2. commit 82a19035d000c8b4fd7d6f61b614f63dec75d389 > Author: Lendacky, Thomas > Date: Fri Jan 16 12:47:16 2015 -0600 > > amd-xgbe: Add ACPI support > >>> + if (!wdt->rate) >>> + ret = -ENODEV; >>> + } >>> + >>> + if (ret) { >>> dev_warn(&adev->dev, "Clock not found\n"); >>> - ret = PTR_ERR(wdt->clk); >>> goto err; >>> } >> >> >> Please move the error handling to where the error occurs. While doing that, >> please change the message to dev_err() - this is an error, not a warning - >> and change the second error message to match the error (it did not find >> the property). >> >> Also, return directly - the goto just generates another error message >> which is ridiculous. > Thank you, I will add the changes. >> >> Thanks, >> Guenter > > Regards, > Srinath.