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

Input: psmouse - rearrange Focaltech init code

The fact that we were calling focaltech_init() even when Focaltech support
is disabled was confusing. Rearrange the code so that if support is
disabled we continue to fall through the rest of protocol probing code
until we get to full reset that Focaltech devices need to work properly.

Also, replace focaltech_init() with a stub now that it is only called when
protocol is enabled.

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>

+26 -27
+6 -16
drivers/input/mouse/focaltech.c
··· 49 49 return 0; 50 50 } 51 51 52 - static void focaltech_reset(struct psmouse *psmouse) 53 - { 54 - ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); 55 - psmouse_reset(psmouse); 56 - } 57 - 58 52 #ifdef CONFIG_MOUSE_PS2_FOCALTECH 59 53 60 54 /* ··· 294 300 return 0; 295 301 } 296 302 303 + static void focaltech_reset(struct psmouse *psmouse) 304 + { 305 + ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); 306 + psmouse_reset(psmouse); 307 + } 308 + 297 309 static void focaltech_disconnect(struct psmouse *psmouse) 298 310 { 299 311 focaltech_reset(psmouse); ··· 456 456 kfree(priv); 457 457 return error; 458 458 } 459 - 460 - #else /* CONFIG_MOUSE_PS2_FOCALTECH */ 461 - 462 - int focaltech_init(struct psmouse *psmouse) 463 - { 464 - focaltech_reset(psmouse); 465 - 466 - return 0; 467 - } 468 - 469 459 #endif /* CONFIG_MOUSE_PS2_FOCALTECH */
+8
drivers/input/mouse/focaltech.h
··· 18 18 #define _FOCALTECH_H 19 19 20 20 int focaltech_detect(struct psmouse *psmouse, bool set_properties); 21 + 22 + #ifdef CONFIG_MOUSE_PS2_FOCALTECH 21 23 int focaltech_init(struct psmouse *psmouse); 24 + #else 25 + static inline int focaltech_init(struct psmouse *psmouse) 26 + { 27 + return -ENOSYS; 28 + } 29 + #endif 22 30 23 31 #endif
+12 -11
drivers/input/mouse/psmouse-base.c
··· 750 750 */ 751 751 if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) { 752 752 if (max_proto > PSMOUSE_IMEX) { 753 - if (!set_properties || focaltech_init(psmouse) == 0) { 754 - if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH)) 755 - return PSMOUSE_FOCALTECH; 756 - /* 757 - * Note that we need to also restrict 758 - * psmouse_max_proto so that psmouse_initialize() 759 - * does not try to reset rate and resolution, 760 - * because even that upsets the device. 761 - */ 762 - psmouse_max_proto = PSMOUSE_PS2; 763 - return PSMOUSE_PS2; 753 + if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH) && 754 + (!set_properties || focaltech_init(psmouse) == 0)) { 755 + return PSMOUSE_FOCALTECH; 764 756 } 765 757 } 758 + /* 759 + * Restrict psmouse_max_proto so that psmouse_initialize() 760 + * does not try to reset rate and resolution, because even 761 + * that upsets the device. 762 + * This also causes us to basically fall through to basic 763 + * protocol detection, where we fully reset the mouse, 764 + * and set it up as bare PS/2 protocol device. 765 + */ 766 + psmouse_max_proto = max_proto = PSMOUSE_PS2; 766 767 } 767 768 768 769 /*