diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c index 74625f4a21a5d567e92d6f2f61aa1a4292fe69f3..a13d9b4b57afa76f7a0113c9e8e3b6cb35876039 100644 --- a/drivers/input/touchscreen/ucb1400_ts.c +++ b/drivers/input/touchscreen/ucb1400_ts.c @@ -204,7 +204,7 @@ static void ucb1400_clear_pending_irq(struct ucb1400_ts *ucb) static void ucb1400_poll_touch(struct ucb1400_ts *ucb, struct touch_data *data) { - bool penup, discard; + bool penup, discard, is_pendown = false; int ret; int hys_down = SECO_INF_DOWN_HYSTERESIS; @@ -220,6 +220,8 @@ static void ucb1400_poll_touch(struct ucb1400_ts *ucb, struct touch_data *data) penup = ucb1400_ts_pen_up(ucb); if (!penup) { + is_pendown = true; + ucb1400_adc_enable(ucb->ac97); data->x = ucb1400_ts_read_xpos(ucb); data->y = ucb1400_ts_read_ypos(ucb); @@ -244,6 +246,13 @@ static void ucb1400_poll_touch(struct ucb1400_ts *ucb, struct touch_data *data) discard = true; } + /* + * Stop if the pen wasn't down when entering + * the ucb1400_poll_touch function. + */ + if (!is_pendown) + break; + if (penup || discard) { ret = seco_pen_up_debounce(&ucb->ts_idev->dev, ucb->filter_data.pen_up_start, ucb->pen_up_debounce); @@ -281,15 +290,21 @@ static void ucb1400_poll_touch(struct ucb1400_ts *ucb, struct touch_data *data) msecs_to_jiffies(UCB1400_TS_POLL_PERIOD)); } - ucb1400_ts_event_release(ucb->ts_idev); - /* - * Clear filters on touch-up. Next touch-down won't be - * at exactly the same position, anyway, so data still - * remaining in the filter will only cause trouble - * later on. + * Only send touch-up event, if the pen + * was actually down. */ - seco_init_filter(&ucb->ts_idev->dev, &ucb->filter_data); + if (is_pendown) { + ucb1400_ts_event_release(ucb->ts_idev); + + /* + * Clear filters on touch-up. Next touch-down won't be + * at exactly the same position, anyway, so data still + * remaining in the filter will only cause trouble + * later on. + */ + seco_init_filter(&ucb->ts_idev->dev, &ucb->filter_data); + } } /*