diff options
author | Andriy Gapon <avg@FreeBSD.org> | 2019-10-25 15:38:09 +0000 |
---|---|---|
committer | Andriy Gapon <avg@FreeBSD.org> | 2019-10-25 15:38:09 +0000 |
commit | bb7b803bf2299d512d9eab58d58367c02325dcec (patch) | |
tree | 4c0d7fe46b5302259fd3d7e6f2389fc2564bd4d7 /sys/dev/ow | |
parent | 6c1633e18ae35f3a005699491e6e5006a00546c1 (diff) | |
download | src-bb7b803bf2299d512d9eab58d58367c02325dcec.tar.gz src-bb7b803bf2299d512d9eab58d58367c02325dcec.zip |
owc_gpiobus_read_data: compare times in sbintime_t units
Previously the code used sbttous() before microseconds comparison in one
place, sbttons() and nanoseconds in another, division by SBT_1US and
microseconds in yet another.
Now the code consistently uses multiplication by SBT_1US to convert
microseconds to sbintime_t before comparing them with periods between
calls to sbinuptime(). This is fast, this is precise enough (below
0.03%) and the periods defined by the protocol cannot overflow.
Reviewed by: imp (D22108)
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=354076
Diffstat (limited to 'sys/dev/ow')
-rw-r--r-- | sys/dev/ow/owc_gpiobus.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/dev/ow/owc_gpiobus.c b/sys/dev/ow/owc_gpiobus.c index 6c23faf63104..e0f9509e18db 100644 --- a/sys/dev/ow/owc_gpiobus.c +++ b/sys/dev/ow/owc_gpiobus.c @@ -296,10 +296,10 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing *t, int *bit) do { now = sbinuptime(); GETPIN(sc, &sample); - } while (sbttous(now - then) < t->t_rdv + 2 && sample == 0); + } while (now - then < (t->t_rdv + 2) * SBT_1US && sample == 0); critical_exit(); - if (sbttons(now - then) < t->t_rdv * 1000) + if (now - then < t->t_rdv * SBT_1US) *bit = 1; else *bit = 0; @@ -307,7 +307,7 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing *t, int *bit) /* Wait out the rest of t_slot */ do { now = sbinuptime(); - } while ((now - then) / SBT_1US < t->t_slot); + } while (now - then < t->t_slot * SBT_1US); RELBUS(sc); |