aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/input-mt.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index cb150a1dbaff..b097af269e00 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -365,27 +365,35 @@ static void input_mt_set_slots(struct input_mt *mt,
365 int *slots, int num_pos) 365 int *slots, int num_pos)
366{ 366{
367 struct input_mt_slot *s; 367 struct input_mt_slot *s;
368 int *w = mt->red, *p; 368 int *w = mt->red, j;
369 369
370 for (p = slots; p != slots + num_pos; p++) 370 for (j = 0; j != num_pos; j++)
371 *p = -1; 371 slots[j] = -1;
372 372
373 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { 373 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
374 if (!input_mt_is_active(s)) 374 if (!input_mt_is_active(s))
375 continue; 375 continue;
376 for (p = slots; p != slots + num_pos; p++) 376
377 if (*w++ < 0) 377 for (j = 0; j != num_pos; j++) {
378 *p = s - mt->slots; 378 if (w[j] < 0) {
379 slots[j] = s - mt->slots;
380 break;
381 }
382 }
383
384 w += num_pos;
379 } 385 }
380 386
381 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { 387 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
382 if (input_mt_is_active(s)) 388 if (input_mt_is_active(s))
383 continue; 389 continue;
384 for (p = slots; p != slots + num_pos; p++) 390
385 if (*p < 0) { 391 for (j = 0; j != num_pos; j++) {
386 *p = s - mt->slots; 392 if (slots[j] < 0) {
393 slots[j] = s - mt->slots;
387 break; 394 break;
388 } 395 }
396 }
389 } 397 }
390} 398}
391 399