Commit c8a9f374 authored by Alessandro Rubini's avatar Alessandro Rubini

kernel: fix buglet in calculation

There was an error in the overflow check of coarse values.
This replaces "> 125*1000*100" with ">= 125*1000*1000"
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 7ba252aa
......@@ -106,7 +106,7 @@ int fd_read_sw_fifo(struct fd_dev *fd, struct zio_channel *chan)
t.coarse += 125000000;
t.coarse &= 0xfffffff;
t.utc--;
} else if(t.coarse > 125000000) {
} else if(t.coarse >= 125000000) {
t.coarse -= 125000000;
t.utc++;
}
......
......@@ -407,7 +407,7 @@ static void fd_attr_add(uint32_t *a, uint32_t pico)
coarse++;
}
a[__COARSE] += coarse;
if (a[__COARSE] > 125*1000*1000) {
if (a[__COARSE] >= 125*1000*1000) {
a[__COARSE] -= 125*1000*1000;
a[__UTC_L]++;
if (unlikely(a[__UTC_L] == 0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment