Skip to content

Commit d09ac61

Browse files
arndbdtor
authored andcommitted
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 <[email protected]> Patchwork-Id: 10076621 Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 59d805a commit d09ac61

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

drivers/input/serio/hp_sdc.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static void hp_sdc_take(int irq, void *dev_id, uint8_t status, uint8_t data)
193193
curr->seq[curr->idx++] = status;
194194
curr->seq[curr->idx++] = data;
195195
hp_sdc.rqty -= 2;
196-
do_gettimeofday(&hp_sdc.rtv);
196+
hp_sdc.rtime = ktime_get();
197197

198198
if (hp_sdc.rqty <= 0) {
199199
/* All data has been gathered. */
@@ -306,13 +306,10 @@ static void hp_sdc_tasklet(unsigned long foo)
306306
write_lock_irq(&hp_sdc.rtq_lock);
307307

308308
if (hp_sdc.rcurr >= 0) {
309-
struct timeval tv;
309+
ktime_t now = ktime_get();
310310

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))) {
316313
hp_sdc_transaction *curr;
317314
uint8_t tmp;
318315

@@ -321,8 +318,8 @@ static void hp_sdc_tasklet(unsigned long foo)
321318
* we'll need to figure out a way to communicate
322319
* it back to the application. and be less verbose.
323320
*/
324-
printk(KERN_WARNING PREFIX "read timeout (%ius)!\n",
325-
(int)(tv.tv_usec - hp_sdc.rtv.tv_usec));
321+
printk(KERN_WARNING PREFIX "read timeout (%lldus)!\n",
322+
ktime_us_delta(now, hp_sdc.rtime));
326323
curr->idx += hp_sdc.rqty;
327324
hp_sdc.rqty = 0;
328325
tmp = curr->seq[curr->actidx];
@@ -551,7 +548,7 @@ unsigned long hp_sdc_put(void)
551548

552549
/* Start a new read */
553550
hp_sdc.rqty = curr->seq[curr->idx];
554-
do_gettimeofday(&hp_sdc.rtv);
551+
hp_sdc.rtime = ktime_get();
555552
curr->idx++;
556553
/* Still need to lock here in case of spurious irq. */
557554
write_lock_irq(&hp_sdc.rtq_lock);

include/linux/hp_sdc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ typedef struct {
281281
hp_sdc_transaction *tq[HP_SDC_QUEUE_LEN]; /* All pending read/writes */
282282

283283
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 */
285285
int wcurr; /* Current write transact in process */
286286

287287
int dev_err; /* carries status from registration */

0 commit comments

Comments
 (0)