[RFC Patch 2/4] mfd: AXP20x: Add power supply sub-driver
Bruno Prémont
bonbons at linux-vserver.org
Mon Nov 3 12:14:56 PST 2014
On Thu, 23 October 2014 Edgar Toernig <froese at gmx.de> wrote:
> > + getnstimeofday(&ts);
> > + /* only query hardware if our data is stale */
> > + spin_lock(&devdata->lock);
> > + if (!init && !(ts.tv_sec > devdata->next_check.tv_sec ||
> > + ts.tv_nsec > devdata->next_check.tv_sec)) {
> > + spin_unlock(&devdata->lock);
> > + return 0;
> > + }
> > + spin_unlock(&devdata->lock);
>
> That time comparison is broken - it compares nsec with sec and
> doesn't check that secs are equal before comparing the nsecs.
> There's timespec_compare which gets it right.
Oops, yeah, going to switch to timespec_compare().
Thanks for spotting!
> Btw, you are aware that the timeofday is a user adjustable
> value? If I ever turn back system time I won't get power
> data any more until the old (future) time is reached.
Huh, no, I didn't consider that.
> Wouldn't it be easier to simply use jiffies and limit the
> poll rate to one second or so?
I considered limiting to some arbitrary polling rate though think
it's better to give users the option to query values more often,
up to the rate at which the value are measured by AXP.
As the AXP's measurement rate is configurable (not exposed by
driver) it's better to base on that setting instead of having
to care at the time of exposing the configuration knob.
Thus jiffies seem to be a bit at their limit. Is using ktime better?
Bruno
More information about the linux-arm-kernel
mailing list