Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1406822imm; Tue, 10 Jul 2018 00:59:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFVeAQ5GGtRYsvI/1UIzbAmJ87KNxtXKdd0ZWqeTt6dzX4crQKvgInWVH5Fz/SCgVZ9bbq X-Received: by 2002:a17:902:b18e:: with SMTP id s14-v6mr22002783plr.44.1531209542103; Tue, 10 Jul 2018 00:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531209542; cv=none; d=google.com; s=arc-20160816; b=IpJAklr0D1f1F9YgvCEtPYLDK7X+Qqtiwu2o/UPk2/TkLnpJ9fJGoq16lfOBzLkTQT Qxf/lqixDXHQPlhgQ5xcQKLUL10jrMWmiqqWXcy7kBL8wu9FLo8oxuq3AMYxnPMCGzqV HBLUQCmzUO/K3UEJBZFW5OoWW3bNSOdgbcmjKQd8NJgXXn3VqE3/6Ky19Wdxl8TGFvxh 5QqBAzbt3ucX7BLv44DTqLG9rI7n99c4uH76OB9M2wLP6JiAS9SerbRU0pTHDPbVtQ7b Kll7qD75WgAlYWQLIGrMWIPNqjvHFg15svUnAelIn53Ut4JrFjXchGBNCmAfna9THZi3 4b4g== 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=Y4EnCWaOAVUF5B+AODLodIl188bLvbImybQ4iXvlSoI=; b=jmPzkC9xYbpju9x8U3KjR+be7JPV8pphDiGD6ZscVirh/YkCxjjwlRHdTQlRGzxZ3q kK9uCC/H4fzOVFcQWGsTL/dw9FquAXmFp8+F2yDHGIsr309/8W3rfYUCnt0ITN870x0c Hw3fTZtEI+MNTER3lkUkUsVRlZw6BqCxMeM4yc4HV3/HGvZ6xX+8B/20875pZSjo6a54 csJMYOIrqjMvm8jGRZ9T6odwppY3jiprOYGvUcSnBAHwSFPmRfB3rx8NaXQHvMoa3fuN qUrtUnVcKmHr8QmZNUkz4jyE2Gg6Aqro38kMHGDPEro/HUarUKLqC4i4nnaHzXyNWaGV fSZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Feg8qrj+; 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.00.58.47; Tue, 10 Jul 2018 00:59: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=Feg8qrj+; 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 S1751219AbeGJH57 (ORCPT + 99 others); Tue, 10 Jul 2018 03:57:59 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:44457 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751057AbeGJH55 (ORCPT ); Tue, 10 Jul 2018 03:57:57 -0400 Received: by mail-oi0-f67.google.com with SMTP id s198-v6so40877441oih.11 for ; Tue, 10 Jul 2018 00:57:57 -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=Y4EnCWaOAVUF5B+AODLodIl188bLvbImybQ4iXvlSoI=; b=Feg8qrj+HJqf6lef5bjGDnbCqTNKq4QDYzlUV5x3m4ncC2P3ol/w0mEDuTRUBdEgM6 jWwSUC8TUNrZRkYS6KK+EeAdML8FWyJGsacMA7vPp97PmNBmlQNgSgBeI+5CCRTnAyH0 pr9AbgwhEc8C6dj9acybOrziw8PO03XdpIBJc= 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=Y4EnCWaOAVUF5B+AODLodIl188bLvbImybQ4iXvlSoI=; b=RIhkVp3rdEhEj9wIEju/yIw7P91u8hdVxaUzh7rv/iq8IQUadW6NJjbWVQhssQlKxV TrY1wCfKZVHKhCicJdGrJXc6MpkXKptZti/LOxDUTFKyplSgBCpI1ryM4tPVQu8g6Tqm i6S2+DDMRq4tH7Vd2PQuKJS9EIiMI4/My/AjqrSG3f7XrpnU6hDV9tPqJm2QGtgrUql+ bA5VRKJy9OuOZotNdTQLFbA7JnF6sw+bgYQSW5fPtp9sjDwXMiCsrL/Nq1B+/bsVG7dT 9IQcaj7V7Itu98JypYB9MLbFEI+MsMMipuJah33tGZT/o6jifufFGQ4zDWUbBjd5UUgo p4fA== X-Gm-Message-State: APt69E2IoC2/wuGegXxmrwmqyBFhBcrlct44GANrTOGtLQdpkEhwdjjQ J9hMXrWRG8yaNR3JJ6OLozm/cgk0NtibORhjiR/nRA== X-Received: by 2002:aca:ccc4:: with SMTP id c187-v6mr24866551oig.282.1531209476553; Tue, 10 Jul 2018 00:57:56 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:6043:0:0:0:0:0 with HTTP; Tue, 10 Jul 2018 00:57:55 -0700 (PDT) In-Reply-To: <055f7c8a-c3c9-af3a-d762-a26329270e4d@roeck-us.net> 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:27:55 +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, 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. > >> + } 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.