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]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux