cdba-server: Change watch timers to ms

In order to sleep for fractions of a second in alpaca, change the
timeout from seconds to milliseconds.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Bjorn Andersson
2020-10-29 23:43:35 -05:00
parent 0fabe029ba
commit decff00617
3 changed files with 7 additions and 4 deletions

View File

@@ -276,9 +276,9 @@ void watch_add_readfd(int fd, int (*cb)(int, void*), void *data)
list_add(&read_watches, &w->node);
}
void watch_timer_add(int timeout, void (*cb)(void *), void *data)
void watch_timer_add(int timeout_ms, void (*cb)(void *), void *data)
{
struct timeval tv_timeout = { timeout, };
struct timeval tv_timeout;
struct timeval now;
struct timer *t;
@@ -286,6 +286,9 @@ void watch_timer_add(int timeout, void (*cb)(void *), void *data)
gettimeofday(&now, NULL);
tv_timeout.tv_sec = timeout_ms / 1000;
tv_timeout.tv_usec = (timeout_ms % 1000) * 1000;
t->cb = cb;
t->data = data;
timeradd(&now, &tv_timeout, &t->tv);

View File

@@ -8,7 +8,7 @@
void watch_add_readfd(int fd, int (*cb)(int, void*), void *data);
int watch_add_quit(int (*cb)(int, void*), void *data);
void watch_timer_add(int timeout, void (*cb)(void *), void *data);
void watch_timer_add(int timeout_ms, void (*cb)(void *), void *data);
void watch_quit(void);
int watch_run(void);

View File

@@ -128,7 +128,7 @@ int device_power_on(struct device *device)
device->power_on(device);
if (device->fastboot_key_timeout)
watch_timer_add(device->fastboot_key_timeout, device_release_fastboot_key, device);
watch_timer_add(device->fastboot_key_timeout * 1000, device_release_fastboot_key, device);
return 0;
}