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

Input: psmouse - fix comment style

The module was using non-standard comment style with comment blocks often
starting at the very beginning of a line instead of being aligned with the
code. Let's switch to standard formatting.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Tested-by: Marcin Sochacki <msochacki+kernel@gmail.com>
Tested-by: Till <till2.schaefer@uni-dortmund.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+124 -155
+124 -155
drivers/input/mouse/psmouse-base.c
··· 129 129 * psmouse_process_byte() analyzes the PS/2 data stream and reports 130 130 * relevant events to the input module once full packet has arrived. 131 131 */ 132 - 133 132 psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) 134 133 { 135 134 struct input_dev *dev = psmouse->dev; ··· 218 219 /* 219 220 * __psmouse_set_state() sets new psmouse state and resets all flags. 220 221 */ 221 - 222 222 static inline void __psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) 223 223 { 224 224 psmouse->state = new_state; ··· 226 228 psmouse->last = jiffies; 227 229 } 228 230 229 - 230 231 /* 231 232 * psmouse_set_state() sets new psmouse state and resets all flags and 232 233 * counters while holding serio lock so fighting with interrupt handler 233 234 * is not a concern. 234 235 */ 235 - 236 236 void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state) 237 237 { 238 238 serio_pause_rx(psmouse->ps2dev.serio); ··· 242 246 * psmouse_handle_byte() processes one byte of the input data stream 243 247 * by calling corresponding protocol handler. 244 248 */ 245 - 246 249 static int psmouse_handle_byte(struct psmouse *psmouse) 247 250 { 248 251 psmouse_ret_t rc = psmouse->protocol_handler(psmouse); ··· 284 289 * psmouse_interrupt() handles incoming characters, either passing them 285 290 * for normal processing or gathering them as command response. 286 291 */ 287 - 288 292 static irqreturn_t psmouse_interrupt(struct serio *serio, 289 293 unsigned char data, unsigned int flags) 290 294 { ··· 326 332 } 327 333 328 334 psmouse->packet[psmouse->pktcnt++] = data; 329 - /* 330 - * Check if this is a new device announcement (0xAA 0x00) 331 - */ 335 + 336 + /* Check if this is a new device announcement (0xAA 0x00) */ 332 337 if (unlikely(psmouse->packet[0] == PSMOUSE_RET_BAT && psmouse->pktcnt <= 2)) { 333 338 if (psmouse->pktcnt == 1) { 334 339 psmouse->last = jiffies; ··· 341 348 serio_reconnect(serio); 342 349 goto out; 343 350 } 344 - /* 345 - * Not a new device, try processing first byte normally 346 - */ 351 + 352 + /* Not a new device, try processing first byte normally */ 347 353 psmouse->pktcnt = 1; 348 354 if (psmouse_handle_byte(psmouse)) 349 355 goto out; ··· 350 358 psmouse->packet[psmouse->pktcnt++] = data; 351 359 } 352 360 353 - /* 354 - * See if we need to force resync because mouse was idle for too long 355 - */ 361 + /* 362 + * See if we need to force resync because mouse was idle for 363 + * too long. 364 + */ 356 365 if (psmouse->state == PSMOUSE_ACTIVATED && 357 366 psmouse->pktcnt == 1 && psmouse->resync_time && 358 367 time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) { ··· 369 376 out: 370 377 return IRQ_HANDLED; 371 378 } 372 - 373 379 374 380 /* 375 381 * psmouse_sliced_command() sends an extended PS/2 command to the mouse ··· 393 401 return 0; 394 402 } 395 403 396 - 397 404 /* 398 405 * psmouse_reset() resets the mouse into power-on state. 399 406 */ ··· 412 421 /* 413 422 * Here we set the mouse resolution. 414 423 */ 415 - 416 424 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution) 417 425 { 418 426 static const unsigned char params[] = { 0, 1, 2, 2, 3 }; ··· 428 438 /* 429 439 * Here we set the mouse report rate. 430 440 */ 431 - 432 441 static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate) 433 442 { 434 443 static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 }; ··· 443 454 /* 444 455 * Here we set the mouse scaling. 445 456 */ 446 - 447 457 static void psmouse_set_scale(struct psmouse *psmouse, enum psmouse_scale scale) 448 458 { 449 459 ps2_command(&psmouse->ps2dev, NULL, ··· 453 465 /* 454 466 * psmouse_poll() - default poll handler. Everyone except for ALPS uses it. 455 467 */ 456 - 457 468 static int psmouse_poll(struct psmouse *psmouse) 458 469 { 459 470 return ps2_command(&psmouse->ps2dev, psmouse->packet, ··· 586 599 if (param[0] != 4) 587 600 return -1; 588 601 589 - /* Magic to enable horizontal scrolling on IntelliMouse 4.0 */ 602 + /* Magic to enable horizontal scrolling on IntelliMouse 4.0 */ 590 603 param[0] = 200; 591 604 ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE); 592 605 param[0] = 80; ··· 656 669 if (!psmouse->name) 657 670 psmouse->name = "Mouse"; 658 671 659 - /* 660 - * We have no way of figuring true number of buttons so let's 661 - * assume that the device has 3. 662 - */ 672 + /* 673 + * We have no way of figuring true number of buttons so let's 674 + * assume that the device has 3. 675 + */ 663 676 __set_bit(BTN_MIDDLE, psmouse->dev->keybit); 664 677 } 665 678 ··· 687 700 * Apply default settings to the psmouse structure. Most of them will 688 701 * be overridden by individual protocol initialization routines. 689 702 */ 690 - 691 703 static void psmouse_apply_defaults(struct psmouse *psmouse) 692 704 { 693 705 struct input_dev *input_dev = psmouse->dev; ··· 739 753 * psmouse_extensions() probes for any extensions to the basic PS/2 protocol 740 754 * the mouse may have. 741 755 */ 742 - 743 756 static int psmouse_extensions(struct psmouse *psmouse, 744 757 unsigned int max_proto, bool set_properties) 745 758 { 746 759 bool synaptics_hardware = false; 747 760 748 - /* Always check for focaltech, this is safe as it uses pnp-id matching */ 761 + /* 762 + * Always check for focaltech, this is safe as it uses pnp-id 763 + * matching. 764 + */ 749 765 if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) { 750 766 if (max_proto > PSMOUSE_IMEX) { 751 767 if (!set_properties || focaltech_init(psmouse) == 0) { ··· 765 777 } 766 778 } 767 779 768 - /* 769 - * We always check for lifebook because it does not disturb mouse 770 - * (it only checks DMI information). 771 - */ 780 + /* 781 + * We always check for LifeBook because it does not disturb mouse 782 + * (it only checks DMI information). 783 + */ 772 784 if (psmouse_do_detect(lifebook_detect, psmouse, set_properties) == 0) { 773 785 if (max_proto > PSMOUSE_IMEX) { 774 786 if (!set_properties || lifebook_init(psmouse) == 0) ··· 783 795 } 784 796 } 785 797 786 - /* 787 - * Try Kensington ThinkingMouse (we try first, because synaptics probe 788 - * upsets the thinkingmouse). 789 - */ 790 - 798 + /* 799 + * Try Kensington ThinkingMouse (we try first, because Synaptics 800 + * probe upsets the ThinkingMouse). 801 + */ 791 802 if (max_proto > PSMOUSE_IMEX && 792 803 psmouse_do_detect(thinking_detect, psmouse, set_properties) == 0) { 793 804 return PSMOUSE_THINKPS; 794 805 } 795 806 796 - /* 797 - * Try Synaptics TouchPad. Note that probing is done even if Synaptics protocol 798 - * support is disabled in config - we need to know if it is synaptics so we 799 - * can reset it properly after probing for intellimouse. 800 - */ 807 + /* 808 + * Try Synaptics TouchPad. Note that probing is done even if 809 + * Synaptics protocol support is disabled in config - we need to 810 + * know if it is Synaptics so we can reset it properly after 811 + * probing for IntelliMouse. 812 + */ 801 813 if (max_proto > PSMOUSE_PS2 && 802 814 psmouse_do_detect(synaptics_detect, psmouse, set_properties) == 0) { 803 815 synaptics_hardware = true; 804 816 805 817 if (max_proto > PSMOUSE_IMEX) { 806 - /* 807 - * Try activating protocol, but check if support is enabled first, since 808 - * we try detecting Synaptics even when protocol is disabled. 809 - */ 818 + /* 819 + * Try activating protocol, but check if support is 820 + * enabled first, since we try detecting Synaptics 821 + * even when protocol is disabled. 822 + */ 810 823 if (IS_ENABLED(CONFIG_MOUSE_PS2_SYNAPTICS) && 811 824 (!set_properties || synaptics_init(psmouse) == 0)) { 812 825 return PSMOUSE_SYNAPTICS; 813 826 } 814 827 815 - /* 816 - * Some Synaptics touchpads can emulate extended protocols (like IMPS/2). 817 - * Unfortunately Logitech/Genius probes confuse some firmware versions so 818 - * we'll have to skip them. 819 - */ 828 + /* 829 + * Some Synaptics touchpads can emulate extended 830 + * protocols (like IMPS/2). Unfortunately 831 + * Logitech/Genius probes confuse some firmware 832 + * versions so we'll have to skip them. 833 + */ 820 834 max_proto = PSMOUSE_IMEX; 821 835 } 822 - /* 823 - * Make sure that touchpad is in relative mode, gestures (taps) are enabled 824 - */ 836 + 837 + /* 838 + * Make sure that touchpad is in relative mode, gestures 839 + * (taps) are enabled. 840 + */ 825 841 synaptics_reset(psmouse); 826 842 } 827 843 828 - /* 829 - * Try Cypress Trackpad. 830 - * Must try it before Finger Sensing Pad because Finger Sensing Pad probe 831 - * upsets some modules of Cypress Trackpads. 832 - */ 844 + /* 845 + * Try Cypress Trackpad. We must try it before Finger Sensing Pad 846 + * because Finger Sensing Pad probe upsets some modules of Cypress 847 + * Trackpads. 848 + */ 833 849 if (max_proto > PSMOUSE_IMEX && 834 850 cypress_detect(psmouse, set_properties) == 0) { 835 851 if (IS_ENABLED(CONFIG_MOUSE_PS2_CYPRESS)) { ··· 851 859 max_proto = PSMOUSE_IMEX; 852 860 } 853 861 854 - /* 855 - * Try ALPS TouchPad 856 - */ 862 + /* Try ALPS TouchPad */ 857 863 if (max_proto > PSMOUSE_IMEX) { 858 864 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); 859 865 if (psmouse_do_detect(alps_detect, 860 866 psmouse, set_properties) == 0) { 861 867 if (!set_properties || alps_init(psmouse) == 0) 862 868 return PSMOUSE_ALPS; 863 - /* 864 - * Init failed, try basic relative protocols 865 - */ 869 + 870 + /* Init failed, try basic relative protocols */ 866 871 max_proto = PSMOUSE_IMEX; 867 872 } 868 873 } 869 874 870 - /* 871 - * Try OLPC HGPK touchpad. 872 - */ 875 + /* Try OLPC HGPK touchpad */ 873 876 if (max_proto > PSMOUSE_IMEX && 874 877 psmouse_do_detect(hgpk_detect, psmouse, set_properties) == 0) { 875 878 if (!set_properties || hgpk_init(psmouse) == 0) 876 879 return PSMOUSE_HGPK; 877 - /* 878 - * Init failed, try basic relative protocols 879 - */ 880 + /* Init failed, try basic relative protocols */ 880 881 max_proto = PSMOUSE_IMEX; 881 882 } 882 883 883 - /* 884 - * Try Elantech touchpad. 885 - */ 884 + /* Try Elantech touchpad */ 886 885 if (max_proto > PSMOUSE_IMEX && 887 886 psmouse_do_detect(elantech_detect, psmouse, set_properties) == 0) { 888 887 if (!set_properties || elantech_init(psmouse) == 0) 889 888 return PSMOUSE_ELANTECH; 890 - /* 891 - * Init failed, try basic relative protocols 892 - */ 889 + /* Init failed, try basic relative protocols */ 893 890 max_proto = PSMOUSE_IMEX; 894 891 } 895 892 ··· 900 919 return PSMOUSE_TOUCHKIT_PS2; 901 920 } 902 921 903 - /* 904 - * Try Finger Sensing Pad. We do it here because its probe upsets 905 - * Trackpoint devices (causing TP_READ_ID command to time out). 906 - */ 922 + /* 923 + * Try Finger Sensing Pad. We do it here because its probe upsets 924 + * Trackpoint devices (causing TP_READ_ID command to time out). 925 + */ 907 926 if (max_proto > PSMOUSE_IMEX) { 908 927 if (psmouse_do_detect(fsp_detect, 909 928 psmouse, set_properties) == 0) { 910 929 if (!set_properties || fsp_init(psmouse) == 0) 911 930 return PSMOUSE_FSP; 912 - /* 913 - * Init failed, try basic relative protocols 914 - */ 931 + /* Init failed, try basic relative protocols */ 915 932 max_proto = PSMOUSE_IMEX; 916 933 } 917 934 } 918 935 919 - /* 920 - * Reset to defaults in case the device got confused by extended 921 - * protocol probes. Note that we follow up with full reset because 922 - * some mice put themselves to sleep when they see PSMOUSE_RESET_DIS. 923 - */ 936 + /* 937 + * Reset to defaults in case the device got confused by extended 938 + * protocol probes. Note that we follow up with full reset because 939 + * some mice put themselves to sleep when they see PSMOUSE_RESET_DIS. 940 + */ 924 941 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); 925 942 psmouse_reset(psmouse); 926 943 ··· 934 955 return PSMOUSE_IMPS; 935 956 } 936 957 937 - /* 938 - * Okay, all failed, we have a standard mouse here. The number of the buttons 939 - * is still a question, though. We assume 3. 940 - */ 958 + /* 959 + * Okay, all failed, we have a standard mouse here. The number of 960 + * the buttons is still a question, though. We assume 3. 961 + */ 941 962 psmouse_do_detect(ps2bare_detect, psmouse, set_properties); 942 963 943 964 if (synaptics_hardware) { 944 - /* 945 - * We detected Synaptics hardware but it did not respond to IMPS/2 probes. 946 - * We need to reset the touchpad because if there is a track point on the 947 - * pass through port it could get disabled while probing for protocol 948 - * extensions. 949 - */ 965 + /* 966 + * We detected Synaptics hardware but it did not respond to 967 + * IMPS/2 probes. We need to reset the touchpad because if 968 + * there is a track point on the pass through port it could 969 + * get disabled while probing for protocol extensions. 970 + */ 950 971 psmouse_reset(psmouse); 951 972 } 952 973 ··· 1146 1167 /* 1147 1168 * psmouse_probe() probes for a PS/2 mouse. 1148 1169 */ 1149 - 1150 1170 static int psmouse_probe(struct psmouse *psmouse) 1151 1171 { 1152 1172 struct ps2dev *ps2dev = &psmouse->ps2dev; 1153 1173 unsigned char param[2]; 1154 1174 1155 - /* 1156 - * First, we check if it's a mouse. It should send 0x00 or 0x03 1157 - * in case of an IntelliMouse in 4-byte mode or 0x04 for IM Explorer. 1158 - * Sunrex K8561 IR Keyboard/Mouse reports 0xff on second and subsequent 1159 - * ID queries, probably due to a firmware bug. 1160 - */ 1161 - 1175 + /* 1176 + * First, we check if it's a mouse. It should send 0x00 or 0x03 in 1177 + * case of an IntelliMouse in 4-byte mode or 0x04 for IM Explorer. 1178 + * Sunrex K8561 IR Keyboard/Mouse reports 0xff on second and 1179 + * subsequent ID queries, probably due to a firmware bug. 1180 + */ 1162 1181 param[0] = 0xa5; 1163 1182 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETID)) 1164 1183 return -1; ··· 1165 1188 param[0] != 0x04 && param[0] != 0xff) 1166 1189 return -1; 1167 1190 1168 - /* 1169 - * Then we reset and disable the mouse so that it doesn't generate events. 1170 - */ 1171 - 1191 + /* 1192 + * Then we reset and disable the mouse so that it doesn't generate 1193 + * events. 1194 + */ 1172 1195 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_DIS)) 1173 1196 psmouse_warn(psmouse, "Failed to reset mouse on %s\n", 1174 1197 ps2dev->serio->phys); ··· 1179 1202 /* 1180 1203 * psmouse_initialize() initializes the mouse to a sane state. 1181 1204 */ 1182 - 1183 1205 static void psmouse_initialize(struct psmouse *psmouse) 1184 1206 { 1185 - /* 1186 - * We set the mouse report rate, resolution and scaling. 1187 - */ 1188 - 1207 + /* 1208 + * We set the mouse report rate, resolution and scaling. 1209 + */ 1189 1210 if (psmouse_max_proto != PSMOUSE_PS2) { 1190 1211 psmouse->set_rate(psmouse, psmouse->rate); 1191 1212 psmouse->set_resolution(psmouse, psmouse->resolution); ··· 1194 1219 /* 1195 1220 * psmouse_activate() enables the mouse so that we get motion reports from it. 1196 1221 */ 1197 - 1198 1222 int psmouse_activate(struct psmouse *psmouse) 1199 1223 { 1200 1224 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { ··· 1207 1233 } 1208 1234 1209 1235 /* 1210 - * psmouse_deactivate() puts the mouse into poll mode so that we don't get motion 1211 - * reports from it unless we explicitly request it. 1236 + * psmouse_deactivate() puts the mouse into poll mode so that we don't get 1237 + * motion reports from it unless we explicitly request it. 1212 1238 */ 1213 - 1214 1239 int psmouse_deactivate(struct psmouse *psmouse) 1215 1240 { 1216 1241 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_DISABLE)) { ··· 1222 1249 return 0; 1223 1250 } 1224 1251 1225 - 1226 1252 /* 1227 1253 * psmouse_resync() attempts to re-validate current protocol. 1228 1254 */ 1229 - 1230 1255 static void psmouse_resync(struct work_struct *work) 1231 1256 { 1232 1257 struct psmouse *parent = NULL, *psmouse = ··· 1244 1273 psmouse_deactivate(parent); 1245 1274 } 1246 1275 1247 - /* 1248 - * Some mice don't ACK commands sent while they are in the middle of 1249 - * transmitting motion packet. To avoid delay we use ps2_sendbyte() 1250 - * instead of ps2_command() which would wait for 200ms for an ACK 1251 - * that may never come. 1252 - * As an additional quirk ALPS touchpads may not only forget to ACK 1253 - * disable command but will stop reporting taps, so if we see that 1254 - * mouse at least once ACKs disable we will do full reconnect if ACK 1255 - * is missing. 1256 - */ 1276 + /* 1277 + * Some mice don't ACK commands sent while they are in the middle of 1278 + * transmitting motion packet. To avoid delay we use ps2_sendbyte() 1279 + * instead of ps2_command() which would wait for 200ms for an ACK 1280 + * that may never come. 1281 + * As an additional quirk ALPS touchpads may not only forget to ACK 1282 + * disable command but will stop reporting taps, so if we see that 1283 + * mouse at least once ACKs disable we will do full reconnect if ACK 1284 + * is missing. 1285 + */ 1257 1286 psmouse->num_resyncs++; 1258 1287 1259 1288 if (ps2_sendbyte(&psmouse->ps2dev, PSMOUSE_CMD_DISABLE, 20)) { ··· 1262 1291 } else 1263 1292 psmouse->acks_disable_command = true; 1264 1293 1265 - /* 1266 - * Poll the mouse. If it was reset the packet will be shorter than 1267 - * psmouse->pktsize and ps2_command will fail. We do not expect and 1268 - * do not handle scenario when mouse "upgrades" its protocol while 1269 - * disconnected since it would require additional delay. If we ever 1270 - * see a mouse that does it we'll adjust the code. 1271 - */ 1294 + /* 1295 + * Poll the mouse. If it was reset the packet will be shorter than 1296 + * psmouse->pktsize and ps2_command will fail. We do not expect and 1297 + * do not handle scenario when mouse "upgrades" its protocol while 1298 + * disconnected since it would require additional delay. If we ever 1299 + * see a mouse that does it we'll adjust the code. 1300 + */ 1272 1301 if (!failed) { 1273 1302 if (psmouse->poll(psmouse)) 1274 1303 failed = true; ··· 1285 1314 psmouse_set_state(psmouse, PSMOUSE_RESYNCING); 1286 1315 } 1287 1316 } 1288 - /* 1289 - * Now try to enable mouse. We try to do that even if poll failed and also 1290 - * repeat our attempts 5 times, otherwise we may be left out with disabled 1291 - * mouse. 1292 - */ 1317 + 1318 + /* 1319 + * Now try to enable mouse. We try to do that even if poll failed 1320 + * and also repeat our attempts 5 times, otherwise we may be left 1321 + * out with disabled mouse. 1322 + */ 1293 1323 for (i = 0; i < 5; i++) { 1294 1324 if (!ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { 1295 1325 enabled = true; ··· 1322 1350 /* 1323 1351 * psmouse_cleanup() resets the mouse into power-on state. 1324 1352 */ 1325 - 1326 1353 static void psmouse_cleanup(struct serio *serio) 1327 1354 { 1328 1355 struct psmouse *psmouse = serio_get_drvdata(serio); ··· 1346 1375 if (psmouse->cleanup) 1347 1376 psmouse->cleanup(psmouse); 1348 1377 1349 - /* 1350 - * Reset the mouse to defaults (bare PS/2 protocol). 1351 - */ 1378 + /* 1379 + * Reset the mouse to defaults (bare PS/2 protocol). 1380 + */ 1352 1381 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); 1353 1382 1354 - /* 1355 - * Some boxes, such as HP nx7400, get terribly confused if mouse 1356 - * is not fully enabled before suspending/shutting down. 1357 - */ 1383 + /* 1384 + * Some boxes, such as HP nx7400, get terribly confused if mouse 1385 + * is not fully enabled before suspending/shutting down. 1386 + */ 1358 1387 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE); 1359 1388 1360 1389 if (parent) { ··· 1370 1399 /* 1371 1400 * psmouse_disconnect() closes and frees. 1372 1401 */ 1373 - 1374 1402 static void psmouse_disconnect(struct serio *serio) 1375 1403 { 1376 1404 struct psmouse *psmouse, *parent = NULL; ··· 1568 1598 retval = error; 1569 1599 goto out; 1570 1600 } 1571 - 1572 1601 1573 1602 static int psmouse_reconnect(struct serio *serio) 1574 1603 {