Wall time obtained from do_gettimeofday is susceptible to sudden jumps due to user setting the time or due to NTP. Boot time is constantly increasing time better suited for comparing two timestamps. Signed-off-by: Abhilash Jindal <klock.android@xxxxxxxxx> --- drivers/usb/misc/usbtest.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 0bbafe7..3300aba 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -30,7 +30,7 @@ struct usbtest_param { unsigned sglen; /* outputs */ - struct timeval duration; + ktime_t duration; }; #define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param) @@ -2047,7 +2047,7 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf) struct urb *urb; struct scatterlist *sg; struct usb_sg_request req; - struct timeval start; + ktime_t start; unsigned i; /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */ @@ -2095,7 +2095,7 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf) * FIXME add more tests! cancel requests, verify the data, control * queueing, concurrent read+write threads, and so on. */ - do_gettimeofday(&start); + start = ktime_get_boottime(); switch (param->test_num) { case 0: @@ -2487,13 +2487,7 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf) simple_free_urb(urb); break; } - do_gettimeofday(¶m->duration); - param->duration.tv_sec -= start.tv_sec; - param->duration.tv_usec -= start.tv_usec; - if (param->duration.tv_usec < 0) { - param->duration.tv_usec += 1000 * 1000; - param->duration.tv_sec -= 1; - } + param->duration = ktime_sub(ktime_get_boottime(), start); mutex_unlock(&dev->lock); return retval; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html