Commit d09ac610 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Dmitry Torokhov

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: default avatarArnd Bergmann <arnd@arndb.de>
Patchwork-Id: 10076621
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 59d805af
...@@ -193,7 +193,7 @@ static void hp_sdc_take(int irq, void *dev_id, uint8_t status, uint8_t data) ...@@ -193,7 +193,7 @@ static void hp_sdc_take(int irq, void *dev_id, uint8_t status, uint8_t data)
curr->seq[curr->idx++] = status; curr->seq[curr->idx++] = status;
curr->seq[curr->idx++] = data; curr->seq[curr->idx++] = data;
hp_sdc.rqty -= 2; hp_sdc.rqty -= 2;
do_gettimeofday(&hp_sdc.rtv); hp_sdc.rtime = ktime_get();
if (hp_sdc.rqty <= 0) { if (hp_sdc.rqty <= 0) {
/* All data has been gathered. */ /* All data has been gathered. */
...@@ -306,13 +306,10 @@ static void hp_sdc_tasklet(unsigned long foo) ...@@ -306,13 +306,10 @@ static void hp_sdc_tasklet(unsigned long foo)
write_lock_irq(&hp_sdc.rtq_lock); write_lock_irq(&hp_sdc.rtq_lock);
if (hp_sdc.rcurr >= 0) { if (hp_sdc.rcurr >= 0) {
struct timeval tv; ktime_t now = ktime_get();
do_gettimeofday(&tv); if (ktime_after(now, ktime_add_us(hp_sdc.rtime,
if (tv.tv_sec > hp_sdc.rtv.tv_sec) HP_SDC_MAX_REG_DELAY))) {
tv.tv_usec += USEC_PER_SEC;
if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) {
hp_sdc_transaction *curr; hp_sdc_transaction *curr;
uint8_t tmp; uint8_t tmp;
...@@ -321,8 +318,8 @@ static void hp_sdc_tasklet(unsigned long foo) ...@@ -321,8 +318,8 @@ static void hp_sdc_tasklet(unsigned long foo)
* we'll need to figure out a way to communicate * we'll need to figure out a way to communicate
* it back to the application. and be less verbose. * it back to the application. and be less verbose.
*/ */
printk(KERN_WARNING PREFIX "read timeout (%ius)!\n", printk(KERN_WARNING PREFIX "read timeout (%lldus)!\n",
(int)(tv.tv_usec - hp_sdc.rtv.tv_usec)); ktime_us_delta(now, hp_sdc.rtime));
curr->idx += hp_sdc.rqty; curr->idx += hp_sdc.rqty;
hp_sdc.rqty = 0; hp_sdc.rqty = 0;
tmp = curr->seq[curr->actidx]; tmp = curr->seq[curr->actidx];
...@@ -551,7 +548,7 @@ unsigned long hp_sdc_put(void) ...@@ -551,7 +548,7 @@ unsigned long hp_sdc_put(void)
/* Start a new read */ /* Start a new read */
hp_sdc.rqty = curr->seq[curr->idx]; hp_sdc.rqty = curr->seq[curr->idx];
do_gettimeofday(&hp_sdc.rtv); hp_sdc.rtime = ktime_get();
curr->idx++; curr->idx++;
/* Still need to lock here in case of spurious irq. */ /* Still need to lock here in case of spurious irq. */
write_lock_irq(&hp_sdc.rtq_lock); write_lock_irq(&hp_sdc.rtq_lock);
......
...@@ -281,7 +281,7 @@ typedef struct { ...@@ -281,7 +281,7 @@ typedef struct {
hp_sdc_transaction *tq[HP_SDC_QUEUE_LEN]; /* All pending read/writes */ hp_sdc_transaction *tq[HP_SDC_QUEUE_LEN]; /* All pending read/writes */
int rcurr, rqty; /* Current read transact in process */ int rcurr, rqty; /* Current read transact in process */
struct timeval rtv; /* Time when current read started */ ktime_t rtime; /* Time when current read started */
int wcurr; /* Current write transact in process */ int wcurr; /* Current write transact in process */
int dev_err; /* carries status from registration */ int dev_err; /* carries status from registration */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment