Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp556342imm; Mon, 9 Jul 2018 06:46:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfLlgr9s+iVjFvAM1ErkEIIVUjnQUixM0UvPe3vJLNj4mfrSof9wW5D20HzlmgZoc3wOJ2v X-Received: by 2002:a17:902:9307:: with SMTP id bc7-v6mr20671480plb.292.1531143974504; Mon, 09 Jul 2018 06:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531143974; cv=none; d=google.com; s=arc-20160816; b=jamB/yxfsX09JBnXeUNOitL7vCcaCy592spIOs04yTe55k+0EgJGvPP3W/+lzYgVDE AiYpHFlVmjlqFIH9ww87ekjsUSYpGTGNK1ODEhNq96pcAKcqYnv97JsBFCBiDZyXQP8r 6SUoNpj7x9pheS+5+sHw9I98p6B8wmna++qdvLHwYf9aYOjxRK3TcyrYQpAXOvR/AIqH cIEL/tiPc6bJ6iZFdj4sFvyz7ictMVjRqSYtklZNOl9z3XJkbms0pTV1et3cdspYPWe1 00zD0q8fSe2Z0Z/fCpEgfCDxSBPcADu9NfGaw3Bp/VP50kNYaaSsoXFOwqs6CehvPwQh gKbQ== 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=zbpS9o1JPvpRAmHQXbbxbmUag7fIyBcvY6/yNsiQwRw=; b=v9K30NRoH/AaXJkY2uUe4igQHLWkn5SPc4eBJ9YVSfAJPwwn+KYqS0gILgjbCcbj/y ijPbvPSpD7bZtTJY7lFGYEWJJB7soMwkyg6ztASmdGkLScNkCwVQmHxnPugnnC1U5Kkc zsluDl8npCWx8oqLLWxlye9t+pIA+yWcxacBPUSYJI/oHJW+B4rZq0y41oPnyOsfU47Q vSHqq3ivr+7RUyBm6pW5vUDoOSq5mRjz5gvEetgB8CMuLMTzG08zV7/Lj0vEfl0w5pE6 ELPbvWqnMf4m6JjSBFAh0QSYK7eDibpVkMCT3RqHxams39767YAlhDvLMLe++Xz89Xlt JrYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=eTLiiJLh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h26-v6si15223535pfj.120.2018.07.09.06.45.59; Mon, 09 Jul 2018 06:46:14 -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=fail header.i=@gmail.com header.s=20161025 header.b=eTLiiJLh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754549AbeGINpO (ORCPT + 99 others); Mon, 9 Jul 2018 09:45:14 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:43852 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754508AbeGINpM (ORCPT ); Mon, 9 Jul 2018 09:45:12 -0400 Received: by mail-pf0-f196.google.com with SMTP id y8-v6so13716724pfm.10; Mon, 09 Jul 2018 06:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zbpS9o1JPvpRAmHQXbbxbmUag7fIyBcvY6/yNsiQwRw=; b=eTLiiJLhUojWV5TkwdYQIdIah3TMpYHYjULmT1vHCbA+nPT8nEyf00rTC62m6U/xtw z80i7pIdGr3w7q/6udu+dEBKd8TVWLAB51+kVama2swMGDOCxLjIRYbGdsyMXjBWCg1E i/EBS0yE7SAR7J/i1npH9pSYaPkpSSi6nu0ly5eO4RUHyh+Sp+yCOQ9nLmmCQa7u5T4b Omn/WqA38G1xB+ZIWp3Yep31Km0KiCd8oFWBp1NTW1eVRSvulVt6ipD5KdXHF/yuTKfQ b4bLotzMxpPPO5W5V78tDbh7gEdAb15Z/McD8bdaUhQ1jGSBZyYhUKdyypygiqu/LZ+v uCmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zbpS9o1JPvpRAmHQXbbxbmUag7fIyBcvY6/yNsiQwRw=; b=Gk8KGuqj+2YZgKU7otSoRTncnJ//2P76am1F/Ega7WF4mzP8nTyJiIHpLI+JiXCvC3 Gt+ZY3bQ2JVZyY1DI91i15g9tR5QXlsY/OxS7F/UrGf0+GTFZaAoXDp10B+b3rY1vDe7 zxAXIUMbjzsSDhGvA50LcG+ZtvjY69aoVWq7xGz0c+JbvQFboww7CLXTO3koUvfaB96U k986VqTojpysJI3hVZxLWdTknyte7cgBugNlh5ap8B/XRJ1dT/Cn47+zEAGbqEXWCvKy LrucqoF2b5Dorxq3kfN4yDhsDwPJqKQN4Pd4nPg8WhJ7wy/qkLwxBWSDrzSEUSswYMxt PeAg== X-Gm-Message-State: APt69E2UIQ/WVs4VXfeZzUvwHvnus9bt8oegCyu06UbRI1UHAinXJmwG abJ3a/ZlQLYw8oas1CsjG1hczw== X-Received: by 2002:a65:57c9:: with SMTP id q9-v6mr19261774pgr.128.1531143911943; Mon, 09 Jul 2018 06:45:11 -0700 (PDT) Received: from server.roeck-us.net (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id d17-v6sm21370846pgp.50.2018.07.09.06.45.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 06:45:10 -0700 (PDT) Subject: Re: [RFC PATCH v2] watchdog: sp805: Add clock-frequency property To: Srinath Mannam , wim@linux-watchdog.org Cc: ray.jui@broadcom.com, vladimir.olovyannikov@broadcom.com, vikram.prakash@broadcom.com, scott.branden@broadcom.com, sudeep.holla@arm.com, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org References: <1531131569-13727-1-git-send-email-srinath.mannam@broadcom.com> From: Guenter Roeck Message-ID: <055f7c8a-c3c9-af3a-d762-a26329270e4d@roeck-us.net> Date: Mon, 9 Jul 2018 06:45:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1531131569-13727-1-git-send-email-srinath.mannam@broadcom.com> 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 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. > + } else > + wdt->rate = clk_get_rate(wdt->clk); The else branch should be in { } as well per coding style. > + } 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. 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. > + 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. Thanks, Guenter