aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-multitouch.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2013-02-27 10:23:15 -0500
committerJiri Kosina <jkosina@suse.cz>2013-03-07 09:20:25 -0500
commit5b62efd8250d6a751c31d1972e96bfccd19c4679 (patch)
treefa38a2e5f651602dddb0014677d92048f64e0d77 /drivers/hid/hid-multitouch.c
parent48a732dfaa77a4dfec803aa8f248373998704f76 (diff)
HID: multitouch: remove useless last_field_index field
The aim of last_field_index was to detect the end of the report. With the introduction of .report(), it is not required anymore to detect it on the fly as we can put it in the right place during the .report(). The resulting code path is simpler to read because the terminating condition is not evaluated after each field. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-multitouch.c')
-rw-r--r--drivers/hid/hid-multitouch.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 7a1ebb867cf4..3f6849ddd29c 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -86,7 +86,6 @@ struct mt_device {
86 multitouch fields */ 86 multitouch fields */
87 int cc_index; /* contact count field index in the report */ 87 int cc_index; /* contact count field index in the report */
88 int cc_value_index; /* contact count value index in the field */ 88 int cc_value_index; /* contact count value index in the field */
89 unsigned last_field_index; /* last field index of the report */
90 unsigned last_slot_field; /* the last field of a slot */ 89 unsigned last_slot_field; /* the last field of a slot */
91 unsigned mt_report_id; /* the report ID of the multitouch device */ 90 unsigned mt_report_id; /* the report ID of the multitouch device */
92 __s8 inputmode; /* InputMode HID feature, -1 if non-existent */ 91 __s8 inputmode; /* InputMode HID feature, -1 if non-existent */
@@ -405,7 +404,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
405 } 404 }
406 405
407 mt_store_field(usage, td, hi); 406 mt_store_field(usage, td, hi);
408 td->last_field_index = field->index;
409 return 1; 407 return 1;
410 case HID_GD_Y: 408 case HID_GD_Y:
411 if (prev_usage && (prev_usage->hid == usage->hid)) { 409 if (prev_usage && (prev_usage->hid == usage->hid)) {
@@ -421,7 +419,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
421 } 419 }
422 420
423 mt_store_field(usage, td, hi); 421 mt_store_field(usage, td, hi);
424 td->last_field_index = field->index;
425 return 1; 422 return 1;
426 } 423 }
427 return 0; 424 return 0;
@@ -436,21 +433,17 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
436 ABS_MT_DISTANCE, 0, 1, 0, 0); 433 ABS_MT_DISTANCE, 0, 1, 0, 0);
437 } 434 }
438 mt_store_field(usage, td, hi); 435 mt_store_field(usage, td, hi);
439 td->last_field_index = field->index;
440 return 1; 436 return 1;
441 case HID_DG_CONFIDENCE: 437 case HID_DG_CONFIDENCE:
442 mt_store_field(usage, td, hi); 438 mt_store_field(usage, td, hi);
443 td->last_field_index = field->index;
444 return 1; 439 return 1;
445 case HID_DG_TIPSWITCH: 440 case HID_DG_TIPSWITCH:
446 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); 441 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
447 input_set_capability(hi->input, EV_KEY, BTN_TOUCH); 442 input_set_capability(hi->input, EV_KEY, BTN_TOUCH);
448 mt_store_field(usage, td, hi); 443 mt_store_field(usage, td, hi);
449 td->last_field_index = field->index;
450 return 1; 444 return 1;
451 case HID_DG_CONTACTID: 445 case HID_DG_CONTACTID:
452 mt_store_field(usage, td, hi); 446 mt_store_field(usage, td, hi);
453 td->last_field_index = field->index;
454 td->touches_by_report++; 447 td->touches_by_report++;
455 td->mt_report_id = field->report->id; 448 td->mt_report_id = field->report->id;
456 return 1; 449 return 1;
@@ -461,7 +454,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
461 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field, 454 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
462 cls->sn_width); 455 cls->sn_width);
463 mt_store_field(usage, td, hi); 456 mt_store_field(usage, td, hi);
464 td->last_field_index = field->index;
465 return 1; 457 return 1;
466 case HID_DG_HEIGHT: 458 case HID_DG_HEIGHT:
467 hid_map_usage(hi, usage, bit, max, 459 hid_map_usage(hi, usage, bit, max,
@@ -473,7 +465,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
473 ABS_MT_ORIENTATION, 0, 1, 0, 0); 465 ABS_MT_ORIENTATION, 0, 1, 0, 0);
474 } 466 }
475 mt_store_field(usage, td, hi); 467 mt_store_field(usage, td, hi);
476 td->last_field_index = field->index;
477 return 1; 468 return 1;
478 case HID_DG_TIPPRESSURE: 469 case HID_DG_TIPPRESSURE:
479 hid_map_usage(hi, usage, bit, max, 470 hid_map_usage(hi, usage, bit, max,
@@ -481,17 +472,14 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
481 set_abs(hi->input, ABS_MT_PRESSURE, field, 472 set_abs(hi->input, ABS_MT_PRESSURE, field,
482 cls->sn_pressure); 473 cls->sn_pressure);
483 mt_store_field(usage, td, hi); 474 mt_store_field(usage, td, hi);
484 td->last_field_index = field->index;
485 return 1; 475 return 1;
486 case HID_DG_CONTACTCOUNT: 476 case HID_DG_CONTACTCOUNT:
487 td->cc_index = field->index; 477 td->cc_index = field->index;
488 td->cc_value_index = usage->usage_index; 478 td->cc_value_index = usage->usage_index;
489 td->last_field_index = field->index;
490 return 1; 479 return 1;
491 case HID_DG_CONTACTMAX: 480 case HID_DG_CONTACTMAX:
492 /* we don't set td->last_slot_field as contactcount and 481 /* we don't set td->last_slot_field as contactcount and
493 * contact max are global to the report */ 482 * contact max are global to the report */
494 td->last_field_index = field->index;
495 return -1; 483 return -1;
496 case HID_DG_TOUCH: 484 case HID_DG_TOUCH:
497 /* Legacy devices use TIPSWITCH and not TOUCH. 485 /* Legacy devices use TIPSWITCH and not TOUCH.
@@ -677,10 +665,6 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field,
677 /* we only take into account the last report. */ 665 /* we only take into account the last report. */
678 if (usage->hid == td->last_slot_field) 666 if (usage->hid == td->last_slot_field)
679 mt_complete_slot(td, field->hidinput->input); 667 mt_complete_slot(td, field->hidinput->input);
680
681 if (field->index == td->last_field_index
682 && td->num_received >= td->num_expected)
683 mt_sync_frame(td, field->hidinput->input);
684 } 668 }
685 669
686 } 670 }
@@ -721,6 +705,9 @@ static void mt_report(struct hid_device *hid, struct hid_report *report)
721 mt_process_mt_event(hid, field, &field->usage[n], 705 mt_process_mt_event(hid, field, &field->usage[n],
722 field->value[n]); 706 field->value[n]);
723 } 707 }
708
709 if (td->num_received >= td->num_expected)
710 mt_sync_frame(td, report->field[0]->hidinput->input);
724} 711}
725 712
726static void mt_set_input_mode(struct hid_device *hdev) 713static void mt_set_input_mode(struct hid_device *hdev)