linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Brandt <Chris.Brandt@renesas.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	"linux-watchdog@vger.kernel.org" <linux-watchdog@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>,
	Simon Horman <horms+renesas@verge.net.au>
Subject: RE: [PATCH v2 1/2] watchdog: rza_wdt: Support longer timeouts
Date: Thu, 6 Sep 2018 21:39:30 +0000	[thread overview]
Message-ID: <TY1PR01MB1562E9684200CF49FFD095F38A010@TY1PR01MB1562.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20180906185643.GA25704@roeck-us.net>

On Thursday, September 06, 2018, Guenter Roeck wrote:
> > > +	u16 counter;
> > > +
> > > +	if (priv->cks == CKS_4BIT) {
> > > +		counter = DIV_ROUND_UP((timeout * rate),  4194304) + 1;
> >
> > two spaces ?
> >
> > Also, I am not sure how this prevents overflows. Was't the concern
> > that timeout * rate might overflow an int ?

Actually, I don't have to care about math overflows for large timeout 
values because the driver sets a max timeout value.

	if (priv->cks == CKS_4BIT) {
		/* Assume slowest clock rate possible (CKS=0xF) */
		priv->wdev.max_timeout = (4194304 * U8_MAX) / rate;


So if a user sends a timeout greater than that, the upper layer returns 
'Invalid argument' before it ever gets to the driver.

I guess that technically means I don't really have to do the
	if (counter > 256)
		counter = 256;
either because I will never get a timeout value greater than my max.

  (but, I might keep it in there anyway)

Chris

  parent reply	other threads:[~2018-09-07  2:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 18:37 [PATCH v2 0/2] watchdog: Add support for RZ/A2 wdt Chris Brandt
2018-09-06 18:37 ` [PATCH v2 1/2] watchdog: rza_wdt: Support longer timeouts Chris Brandt
2018-09-06 18:52   ` Guenter Roeck
2018-09-06 18:56     ` Guenter Roeck
2018-09-06 19:40       ` Chris Brandt
2018-09-06 19:40         ` Chris Brandt
2018-09-06 21:39       ` Chris Brandt [this message]
2018-09-06 20:45     ` Chris Brandt
2018-09-06 18:37 ` [PATCH v2 2/2] dt-bindings: watchdog: renesas-wdt: Add support for R7S9210 Chris Brandt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=TY1PR01MB1562E9684200CF49FFD095F38A010@TY1PR01MB1562.jpnprd01.prod.outlook.com \
    --to=chris.brandt@renesas.com \
    --cc=devicetree@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=horms+renesas@verge.net.au \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=wim@linux-watchdog.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).