diff options
author | Aaron Durbin <adurbin@chromium.org> | 2014-09-23 16:34:40 -0500 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-03-21 17:00:40 +0100 |
commit | 46ba4807e926720b8361a4e271cb1fa022f5abc5 (patch) | |
tree | 9bd7d58985c618b8ff2afd14ffbd154fa88c0b83 /src/device/software_i2c.c | |
parent | ad5a909740720931849a9565730209ad97ad48f5 (diff) |
device: convert to stopwatch API
Instead of open coding the monotonic timers use the stopwatch
abstraction.
BUG=None
BRANCH=None
TEST=Booted and noted timings work as expected. Built with software_i2c
and no compilation failures.
Change-Id: Ie5ecdd5bc764c1ab8ba4a923e65a1666aacd22f7
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: c7bffb5aeb41e9b88cd2c99edd6abc38f1dc90af
Original-Change-Id: I0170fe4b93d9976957a2dcb00a6ea41ddc0320ce
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/219495
Original-Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: http://review.coreboot.org/8817
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/device/software_i2c.c')
-rw-r--r-- | src/device/software_i2c.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/device/software_i2c.c b/src/device/software_i2c.c index 6c9c200dc7..518aa5faf7 100644 --- a/src/device/software_i2c.c +++ b/src/device/software_i2c.c @@ -44,20 +44,21 @@ static int __wait(unsigned bus, int timeout_us, int for_scl) int us; int sda = software_i2c[bus]->get_sda(bus); int scl = software_i2c[bus]->get_scl(bus); - struct mono_time start; - timer_monotonic_get(&start); + struct stopwatch sw; + + stopwatch_init_usecs_expire(&sw, timeout_us); do { int old_sda = sda; int old_scl = scl; - struct rela_time diff = current_time_from(&start); - us = rela_time_in_microseconds(&diff); + + us = stopwatch_duration_usecs(&sw); if (old_sda != (sda = software_i2c[bus]->get_sda(bus))) spew("[SDA transitioned to %d after %dus] ", sda, us); if (old_scl != (scl = software_i2c[bus]->get_scl(bus))) spew("[SCL transitioned to %d after %dus] ", scl, us); - } while (us < timeout_us && (!for_scl || !scl)); + } while (!stopwatch_expired(&sw) && (!for_scl || !scl)); return scl; } |