aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/ads7846.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/ads7846.c')
-rw-r--r--drivers/input/touchscreen/ads7846.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index c34e59b720a6..d983cc51ad32 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -54,7 +54,8 @@
54 * files. 54 * files.
55 */ 55 */
56 56
57#define TS_POLL_PERIOD msecs_to_jiffies(10) 57#define TS_POLL_DELAY (1 * 1000000) /* ns delay before the first sample */
58#define TS_POLL_PERIOD (5 * 1000000) /* ns delay between samples */
58 59
59/* this driver doesn't aim at the peak continuous sample rate */ 60/* this driver doesn't aim at the peak continuous sample rate */
60#define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */) 61#define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */)
@@ -99,7 +100,7 @@ struct ads7846 {
99 u16 debounce_rep; 100 u16 debounce_rep;
100 101
101 spinlock_t lock; 102 spinlock_t lock;
102 struct timer_list timer; /* P: lock */ 103 struct hrtimer timer;
103 unsigned pendown:1; /* P: lock */ 104 unsigned pendown:1; /* P: lock */
104 unsigned pending:1; /* P: lock */ 105 unsigned pending:1; /* P: lock */
105// FIXME remove "irq_disabled" 106// FIXME remove "irq_disabled"
@@ -407,10 +408,12 @@ static void ads7846_rx(void *ads)
407 Rt = 0; 408 Rt = 0;
408 409
409 /* Sample found inconsistent by debouncing or pressure is beyond 410 /* Sample found inconsistent by debouncing or pressure is beyond
410 * the maximum. Don't report it to user space, repeat at least 411 * the maximum. Don't report it to user space, repeat at least
411 * once more the measurement */ 412 * once more the measurement
413 */
412 if (ts->tc.ignore || Rt > ts->pressure_max) { 414 if (ts->tc.ignore || Rt > ts->pressure_max) {
413 mod_timer(&ts->timer, jiffies + TS_POLL_PERIOD); 415 hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD),
416 HRTIMER_REL);
414 return; 417 return;
415 } 418 }
416 419
@@ -452,7 +455,7 @@ static void ads7846_rx(void *ads)
452 spin_lock_irqsave(&ts->lock, flags); 455 spin_lock_irqsave(&ts->lock, flags);
453 456
454 ts->pendown = (Rt != 0); 457 ts->pendown = (Rt != 0);
455 mod_timer(&ts->timer, jiffies + TS_POLL_PERIOD); 458 hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), HRTIMER_REL);
456 459
457 spin_unlock_irqrestore(&ts->lock, flags); 460 spin_unlock_irqrestore(&ts->lock, flags);
458} 461}
@@ -543,9 +546,9 @@ static void ads7846_rx_val(void *ads)
543 status); 546 status);
544} 547}
545 548
546static void ads7846_timer(unsigned long handle) 549static int ads7846_timer(struct hrtimer *handle)
547{ 550{
548 struct ads7846 *ts = (void *)handle; 551 struct ads7846 *ts = container_of(handle, struct ads7846, timer);
549 int status = 0; 552 int status = 0;
550 553
551 spin_lock_irq(&ts->lock); 554 spin_lock_irq(&ts->lock);
@@ -567,6 +570,7 @@ static void ads7846_timer(unsigned long handle)
567 } 570 }
568 571
569 spin_unlock_irq(&ts->lock); 572 spin_unlock_irq(&ts->lock);
573 return HRTIMER_NORESTART;
570} 574}
571 575
572static irqreturn_t ads7846_irq(int irq, void *handle) 576static irqreturn_t ads7846_irq(int irq, void *handle)
@@ -585,7 +589,8 @@ static irqreturn_t ads7846_irq(int irq, void *handle)
585 ts->irq_disabled = 1; 589 ts->irq_disabled = 1;
586 disable_irq(ts->spi->irq); 590 disable_irq(ts->spi->irq);
587 ts->pending = 1; 591 ts->pending = 1;
588 mod_timer(&ts->timer, jiffies); 592 hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_DELAY),
593 HRTIMER_REL);
589 } 594 }
590 } 595 }
591 spin_unlock_irqrestore(&ts->lock, flags); 596 spin_unlock_irqrestore(&ts->lock, flags);
@@ -719,8 +724,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
719 ts->spi = spi; 724 ts->spi = spi;
720 ts->input = input_dev; 725 ts->input = input_dev;
721 726
722 init_timer(&ts->timer); 727 hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_REL);
723 ts->timer.data = (unsigned long) ts;
724 ts->timer.function = ads7846_timer; 728 ts->timer.function = ads7846_timer;
725 729
726 spin_lock_init(&ts->lock); 730 spin_lock_init(&ts->lock);