diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cold-flash.c | 16 | ||||
-rw-r--r-- | src/global.h | 3 | ||||
-rw-r--r-- | src/nolo.c | 2 | ||||
-rw-r--r-- | src/usb-device.c | 2 |
4 files changed, 13 insertions, 10 deletions
diff --git a/src/cold-flash.c b/src/cold-flash.c index 8874b32..eb2ca67 100644 --- a/src/cold-flash.c +++ b/src/cold-flash.c @@ -189,13 +189,13 @@ static int send_2nd(usb_dev_handle * udev, struct image * image) { printf("Sending OMAP peripheral boot message...\n"); ret = usb_bulk_write(udev, WRITE_DEV, (char *)&omap_peripheral_msg, sizeof(omap_peripheral_msg), WRITE_TIMEOUT); - usleep(5000); + SLEEP(5000); if ( ret != sizeof(omap_peripheral_msg) ) ERROR_RETURN("Sending OMAP peripheral boot message failed", -1); printf("Sending 2nd X-Loader image size...\n"); ret = usb_bulk_write(udev, WRITE_DEV, (char *)&image->size, 4, WRITE_TIMEOUT); - usleep(5000); + SLEEP(5000); if ( ret != 4 ) ERROR_RETURN("Sending 2nd X-Loader image size failed", -1); @@ -215,7 +215,7 @@ static int send_2nd(usb_dev_handle * udev, struct image * image) { readed += ret; printf_progressbar(readed, image->size); } - usleep(50000); + SLEEP(50000); return 0; @@ -232,7 +232,7 @@ static int send_secondary(usb_dev_handle * udev, struct image * image) { printf("Sending X-Loader init message...\n"); ret = usb_bulk_write(udev, WRITE_DEV, (char *)&init_msg, sizeof(init_msg), WRITE_TIMEOUT); - usleep(5000); + SLEEP(5000); if ( ret != sizeof(init_msg) ) ERROR_RETURN("Sending X-Loader init message failed", -1); @@ -257,7 +257,7 @@ static int send_secondary(usb_dev_handle * udev, struct image * image) { readed += ret; printf_progressbar(readed, image->size); } - usleep(5000); + SLEEP(5000); printf("Waiting for X-Loader response...\n"); ret = usb_bulk_read(udev, READ_DEV, (char *)&buffer, 4, READ_TIMEOUT); /* 4 bytes - dummy value */ @@ -295,7 +295,7 @@ static int ping_timeout(usb_dev_handle * udev) { break; } - usleep(5000); + SLEEP(5000); --try_read; } @@ -405,11 +405,11 @@ int leave_cold_flash(struct usb_device_info * dev) { printf("Sending OMAP memory boot message...\n"); ret = usb_bulk_write(dev->udev, WRITE_DEV, (char *)&omap_memory_msg, sizeof(omap_memory_msg), WRITE_TIMEOUT); - usleep(5000); + SLEEP(5000); if ( ret != sizeof(omap_memory_msg) ) ERROR_RETURN("Sending OMAP memory boot message failed", -1); - usleep(250000); + SLEEP(250000); return 0; } diff --git a/src/global.h b/src/global.h index e1f0365..991d3b3 100644 --- a/src/global.h +++ b/src/global.h @@ -5,6 +5,7 @@ #include <stdio.h> #include <string.h> #include <errno.h> +#include <time.h> extern int simulate; extern int noverify; @@ -21,4 +22,6 @@ extern int verbose; #define ALLOC_ERROR() do { ERROR("Cannot allocate memory"); } while (0) #define ALLOC_ERROR_RETURN(...) do { ALLOC_ERROR(); return __VA_ARGS__; } while (0) +#define SLEEP(usec) do { struct timespec _t = { 0, (usec) }; nanosleep(&_t, NULL); } while (0) + #endif @@ -537,7 +537,7 @@ int nolo_flash_image(struct usb_device_info * dev, struct image * image) { } - usleep(0xc350); // 0.5s + SLEEP(0xc350); // 0.5s } diff --git a/src/usb-device.c b/src/usb-device.c index 943303b..4fb011a 100644 --- a/src/usb-device.c +++ b/src/usb-device.c @@ -325,7 +325,7 @@ struct usb_device_info * usb_open_and_wait_for_device(void) { if ( ret ) break; - usleep(0xc350); // 0.5s + SLEEP(0xc350); // 0.5s } |