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

Input: elantech - add helper function elantech_is_buttonpad()

We check for this bit all over the code, better have it defined once
for all.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Benjamin Tissoires and committed by
Dmitry Torokhov
88463497 37548659

+49 -44
+49 -44
drivers/input/mouse/elantech.c
··· 230 230 } 231 231 232 232 /* 233 + * Advertise INPUT_PROP_BUTTONPAD for clickpads. The testing of bit 12 in 234 + * fw_version for this is based on the following fw_version & caps table: 235 + * 236 + * Laptop-model: fw_version: caps: buttons: 237 + * Acer S3 0x461f00 10, 13, 0e clickpad 238 + * Acer S7-392 0x581f01 50, 17, 0d clickpad 239 + * Acer V5-131 0x461f02 01, 16, 0c clickpad 240 + * Acer V5-551 0x461f00 ? clickpad 241 + * Asus K53SV 0x450f01 78, 15, 0c 2 hw buttons 242 + * Asus G46VW 0x460f02 00, 18, 0c 2 hw buttons 243 + * Asus G750JX 0x360f00 00, 16, 0c 2 hw buttons 244 + * Asus TP500LN 0x381f17 10, 14, 0e clickpad 245 + * Asus X750JN 0x381f17 10, 14, 0e clickpad 246 + * Asus UX31 0x361f00 20, 15, 0e clickpad 247 + * Asus UX32VD 0x361f02 00, 15, 0e clickpad 248 + * Avatar AVIU-145A2 0x361f00 ? clickpad 249 + * Fujitsu CELSIUS H760 0x570f02 40, 14, 0c 3 hw buttons (**) 250 + * Fujitsu CELSIUS H780 0x5d0f02 41, 16, 0d 3 hw buttons (**) 251 + * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons 252 + * Fujitsu LIFEBOOK E546 0x470f00 50, 12, 09 2 hw buttons 253 + * Fujitsu LIFEBOOK E547 0x470f00 50, 12, 09 2 hw buttons 254 + * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons 255 + * Fujitsu LIFEBOOK E557 0x570f01 40, 14, 0c 2 hw buttons 256 + * Fujitsu T725 0x470f01 05, 12, 09 2 hw buttons 257 + * Fujitsu H730 0x570f00 c0, 14, 0c 3 hw buttons (**) 258 + * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons 259 + * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*) 260 + * Lenovo L530 0x350f02 b9, 15, 0c 2 hw buttons (*) 261 + * Samsung NF210 0x150b00 78, 14, 0a 2 hw buttons 262 + * Samsung NP770Z5E 0x575f01 10, 15, 0f clickpad 263 + * Samsung NP700Z5B 0x361f06 21, 15, 0f clickpad 264 + * Samsung NP900X3E-A02 0x575f03 ? clickpad 265 + * Samsung NP-QX410 0x851b00 19, 14, 0c clickpad 266 + * Samsung RC512 0x450f00 08, 15, 0c 2 hw buttons 267 + * Samsung RF710 0x450f00 ? 2 hw buttons 268 + * System76 Pangolin 0x250f01 ? 2 hw buttons 269 + * (*) + 3 trackpoint buttons 270 + * (**) + 0 trackpoint buttons 271 + * Note: Lenovo L430 and Lenovo L530 have the same fw_version/caps 272 + */ 273 + static inline int elantech_is_buttonpad(struct elantech_device_info *info) 274 + { 275 + return info->fw_version & 0x001000; 276 + } 277 + 278 + /* 233 279 * Interpret complete data packets and report absolute mode input events for 234 280 * hardware version 1. (4 byte packets) 235 281 */ ··· 572 526 input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); 573 527 574 528 /* For clickpads map both buttons to BTN_LEFT */ 575 - if (etd->info.fw_version & 0x001000) 529 + if (elantech_is_buttonpad(&etd->info)) 576 530 input_report_key(dev, BTN_LEFT, packet[0] & 0x03); 577 531 else 578 532 psmouse_report_standard_buttons(dev, packet[0]); ··· 590 544 unsigned char *packet = psmouse->packet; 591 545 592 546 /* For clickpads map both buttons to BTN_LEFT */ 593 - if (etd->info.fw_version & 0x001000) 547 + if (elantech_is_buttonpad(&etd->info)) 594 548 input_report_key(dev, BTN_LEFT, packet[0] & 0x03); 595 549 else 596 550 psmouse_report_standard_buttons(dev, packet[0]); ··· 1066 1020 return 0; 1067 1021 } 1068 1022 1069 - /* 1070 - * Advertise INPUT_PROP_BUTTONPAD for clickpads. The testing of bit 12 in 1071 - * fw_version for this is based on the following fw_version & caps table: 1072 - * 1073 - * Laptop-model: fw_version: caps: buttons: 1074 - * Acer S3 0x461f00 10, 13, 0e clickpad 1075 - * Acer S7-392 0x581f01 50, 17, 0d clickpad 1076 - * Acer V5-131 0x461f02 01, 16, 0c clickpad 1077 - * Acer V5-551 0x461f00 ? clickpad 1078 - * Asus K53SV 0x450f01 78, 15, 0c 2 hw buttons 1079 - * Asus G46VW 0x460f02 00, 18, 0c 2 hw buttons 1080 - * Asus G750JX 0x360f00 00, 16, 0c 2 hw buttons 1081 - * Asus TP500LN 0x381f17 10, 14, 0e clickpad 1082 - * Asus X750JN 0x381f17 10, 14, 0e clickpad 1083 - * Asus UX31 0x361f00 20, 15, 0e clickpad 1084 - * Asus UX32VD 0x361f02 00, 15, 0e clickpad 1085 - * Avatar AVIU-145A2 0x361f00 ? clickpad 1086 - * Fujitsu CELSIUS H760 0x570f02 40, 14, 0c 3 hw buttons (**) 1087 - * Fujitsu CELSIUS H780 0x5d0f02 41, 16, 0d 3 hw buttons (**) 1088 - * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons 1089 - * Fujitsu LIFEBOOK E546 0x470f00 50, 12, 09 2 hw buttons 1090 - * Fujitsu LIFEBOOK E547 0x470f00 50, 12, 09 2 hw buttons 1091 - * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons 1092 - * Fujitsu LIFEBOOK E557 0x570f01 40, 14, 0c 2 hw buttons 1093 - * Fujitsu T725 0x470f01 05, 12, 09 2 hw buttons 1094 - * Fujitsu H730 0x570f00 c0, 14, 0c 3 hw buttons (**) 1095 - * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons 1096 - * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*) 1097 - * Lenovo L530 0x350f02 b9, 15, 0c 2 hw buttons (*) 1098 - * Samsung NF210 0x150b00 78, 14, 0a 2 hw buttons 1099 - * Samsung NP770Z5E 0x575f01 10, 15, 0f clickpad 1100 - * Samsung NP700Z5B 0x361f06 21, 15, 0f clickpad 1101 - * Samsung NP900X3E-A02 0x575f03 ? clickpad 1102 - * Samsung NP-QX410 0x851b00 19, 14, 0c clickpad 1103 - * Samsung RC512 0x450f00 08, 15, 0c 2 hw buttons 1104 - * Samsung RF710 0x450f00 ? 2 hw buttons 1105 - * System76 Pangolin 0x250f01 ? 2 hw buttons 1106 - * (*) + 3 trackpoint buttons 1107 - * (**) + 0 trackpoint buttons 1108 - * Note: Lenovo L430 and Lenovo L530 have the same fw_version/caps 1109 - */ 1110 1023 static void elantech_set_buttonpad_prop(struct psmouse *psmouse) 1111 1024 { 1112 1025 struct input_dev *dev = psmouse->dev; 1113 1026 struct elantech_data *etd = psmouse->private; 1114 1027 1115 - if (etd->info.fw_version & 0x001000) { 1028 + if (elantech_is_buttonpad(&etd->info)) { 1116 1029 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); 1117 1030 __clear_bit(BTN_RIGHT, dev->keybit); 1118 1031 }