Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: hp_sdc - convert to ktime_get()

This gets rid of the deprecated do_gettimeofday() call in favor
of ktime_get(), which is also more reliable as it uses monotonic
times. The code now gets a bit simpler.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Patchwork-Id: 10076621
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Arnd Bergmann and committed by
Dmitry Torokhov
d09ac610 59d805af

+8 -11
+7 -10
drivers/input/serio/hp_sdc.c
··· 193 193 curr->seq[curr->idx++] = status; 194 194 curr->seq[curr->idx++] = data; 195 195 hp_sdc.rqty -= 2; 196 - do_gettimeofday(&hp_sdc.rtv); 196 + hp_sdc.rtime = ktime_get(); 197 197 198 198 if (hp_sdc.rqty <= 0) { 199 199 /* All data has been gathered. */ ··· 306 306 write_lock_irq(&hp_sdc.rtq_lock); 307 307 308 308 if (hp_sdc.rcurr >= 0) { 309 - struct timeval tv; 309 + ktime_t now = ktime_get(); 310 310 311 - do_gettimeofday(&tv); 312 - if (tv.tv_sec > hp_sdc.rtv.tv_sec) 313 - tv.tv_usec += USEC_PER_SEC; 314 - 315 - if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) { 311 + if (ktime_after(now, ktime_add_us(hp_sdc.rtime, 312 + HP_SDC_MAX_REG_DELAY))) { 316 313 hp_sdc_transaction *curr; 317 314 uint8_t tmp; 318 315 ··· 318 321 * we'll need to figure out a way to communicate 319 322 * it back to the application. and be less verbose. 320 323 */ 321 - printk(KERN_WARNING PREFIX "read timeout (%ius)!\n", 322 - (int)(tv.tv_usec - hp_sdc.rtv.tv_usec)); 324 + printk(KERN_WARNING PREFIX "read timeout (%lldus)!\n", 325 + ktime_us_delta(now, hp_sdc.rtime)); 323 326 curr->idx += hp_sdc.rqty; 324 327 hp_sdc.rqty = 0; 325 328 tmp = curr->seq[curr->actidx]; ··· 548 551 549 552 /* Start a new read */ 550 553 hp_sdc.rqty = curr->seq[curr->idx]; 551 - do_gettimeofday(&hp_sdc.rtv); 554 + hp_sdc.rtime = ktime_get(); 552 555 curr->idx++; 553 556 /* Still need to lock here in case of spurious irq. */ 554 557 write_lock_irq(&hp_sdc.rtq_lock);
+1 -1
include/linux/hp_sdc.h
··· 281 281 hp_sdc_transaction *tq[HP_SDC_QUEUE_LEN]; /* All pending read/writes */ 282 282 283 283 int rcurr, rqty; /* Current read transact in process */ 284 - struct timeval rtv; /* Time when current read started */ 284 + ktime_t rtime; /* Time when current read started */ 285 285 int wcurr; /* Current write transact in process */ 286 286 287 287 int dev_err; /* carries status from registration */