Skip to content

Commit

Permalink
Input: psmouse - rearrange Focaltech init code
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Pali Rohár <[email protected]>
Tested-by: Marcin Sochacki <[email protected]>
Tested-by: Till <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
dtor committed Dec 17, 2015
1 parent ad53077 commit 2b6f39e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
22 changes: 6 additions & 16 deletions drivers/input/mouse/focaltech.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ int focaltech_detect(struct psmouse *psmouse, bool set_properties)
return 0;
}

static void focaltech_reset(struct psmouse *psmouse)
{
ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
psmouse_reset(psmouse);
}

#ifdef CONFIG_MOUSE_PS2_FOCALTECH

/*
Expand Down Expand Up @@ -300,6 +294,12 @@ static int focaltech_switch_protocol(struct psmouse *psmouse)
return 0;
}

static void focaltech_reset(struct psmouse *psmouse)
{
ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
psmouse_reset(psmouse);
}

static void focaltech_disconnect(struct psmouse *psmouse)
{
focaltech_reset(psmouse);
Expand Down Expand Up @@ -456,14 +456,4 @@ int focaltech_init(struct psmouse *psmouse)
kfree(priv);
return error;
}

#else /* CONFIG_MOUSE_PS2_FOCALTECH */

int focaltech_init(struct psmouse *psmouse)
{
focaltech_reset(psmouse);

return 0;
}

#endif /* CONFIG_MOUSE_PS2_FOCALTECH */
8 changes: 8 additions & 0 deletions drivers/input/mouse/focaltech.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
#define _FOCALTECH_H

int focaltech_detect(struct psmouse *psmouse, bool set_properties);

#ifdef CONFIG_MOUSE_PS2_FOCALTECH
int focaltech_init(struct psmouse *psmouse);
#else
static inline int focaltech_init(struct psmouse *psmouse)
{
return -ENOSYS;
}
#endif

#endif
23 changes: 12 additions & 11 deletions drivers/input/mouse/psmouse-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,19 +750,20 @@ static int psmouse_extensions(struct psmouse *psmouse,
*/
if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) {
if (max_proto > PSMOUSE_IMEX) {
if (!set_properties || focaltech_init(psmouse) == 0) {
if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH))
return PSMOUSE_FOCALTECH;
/*
* Note that we need to also restrict
* psmouse_max_proto so that psmouse_initialize()
* does not try to reset rate and resolution,
* because even that upsets the device.
*/
psmouse_max_proto = PSMOUSE_PS2;
return PSMOUSE_PS2;
if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH) &&
(!set_properties || focaltech_init(psmouse) == 0)) {
return PSMOUSE_FOCALTECH;
}
}
/*
* Restrict psmouse_max_proto so that psmouse_initialize()
* does not try to reset rate and resolution, because even
* that upsets the device.
* This also causes us to basically fall through to basic
* protocol detection, where we fully reset the mouse,
* and set it up as bare PS/2 protocol device.
*/
psmouse_max_proto = max_proto = PSMOUSE_PS2;
}

/*
Expand Down

0 comments on commit 2b6f39e

Please sign in to comment.