Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: MT - make slot assignment work for overcovered solutions

The recent inclusion of a deassignment cost in the slot assignment
algorithm did not properly account for the corner cases where the
solutions are overcovered. This change makes sure the resulting
assignment is unique, allocating new slots when necessary.

Signed-off-by: Henrik Rydberg <rydberg@bitmath.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Benjamin Tissoires and committed by
Dmitry Torokhov
73e8a8e7 61125591

+17 -9
+17 -9
drivers/input/input-mt.c
··· 365 365 int *slots, int num_pos) 366 366 { 367 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++) 371 - *p = -1; 370 + for (j = 0; j != num_pos; j++) 371 + slots[j] = -1; 372 372 373 373 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { 374 374 if (!input_mt_is_active(s)) 375 375 continue; 376 - for (p = slots; p != slots + num_pos; p++) 377 - if (*w++ < 0) 378 - *p = s - mt->slots; 376 + 377 + for (j = 0; j != num_pos; j++) { 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 387 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { 382 388 if (input_mt_is_active(s)) 383 389 continue; 384 - for (p = slots; p != slots + num_pos; p++) 385 - if (*p < 0) { 386 - *p = s - mt->slots; 390 + 391 + for (j = 0; j != num_pos; j++) { 392 + if (slots[j] < 0) { 393 + slots[j] = s - mt->slots; 387 394 break; 388 395 } 396 + } 389 397 } 390 398 } 391 399