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:
> > > +		if (counter > 255)
> > > +			counter = 0;
> >
> > This is difficult to understand.
> >
> > > +
> > > +		priv->count = 256 - counter;
> >
> > It sets priv->count to 256, meaning that 0x5B00 instead of
> > 0x5Axx will be written into the counter register. That really
> > asks for some explanation.
> >
> 
> No, wait, priv->count is an 8-bit variable, so this really sets
> priv->counter to 0. I am getting more and more confused. Why
> not just set "counter = 256" above to make it obvious if that
> is what is supposed to happen ?

That's a good point.

The math is supposed to be:

  256 - [number of ticks you want] = [register value]

Where [number of ticks you want] must be <= 256

Of course it's 8-bit variable so it will work...but that's not obvious 
at first.

I'll change it to:

	if (counter > 256)
		counter = 256;


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