RE: [PATCH v2 1/2] watchdog: rza_wdt: Support longer timeouts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux