On Tue, Aug 11, 2015 at 11:57:15AM -0400, Abhilash Jindal wrote: > 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 | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) > > diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c > index 0bbafe7..61cc639 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,8 @@ 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_get_boottime(); > + param->duration = ktime_sub(param->duration, start); param->duration = ktime_sub(ktime_get_boottime(), start); -- balbi
Attachment:
signature.asc
Description: Digital signature