Commit 0edcd2c4 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: do not call protocol handler in psmouse unless mouse is

       filly initialized - helps when USB Legacy emulation gets
       in our way and starts generating junk data stream while
       psmouse is detecting hardware
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent a45857d1
......@@ -186,6 +186,9 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
goto out;
}
if (psmouse->state == PSMOUSE_INITIALIZING)
goto out;
if (psmouse->state == PSMOUSE_ACTIVATED &&
psmouse->pktcnt && time_after(jiffies, psmouse->last + HZ/2)) {
printk(KERN_WARNING "psmouse.c: %s at %s lost synchronization, throwing %d bytes away.\n",
......@@ -631,7 +634,7 @@ static void psmouse_initialize(struct psmouse *psmouse)
* is not a concern.
*/
static void psmouse_set_state(struct psmouse *psmouse, unsigned char new_state)
static void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state)
{
serio_pause_rx(psmouse->serio);
psmouse->state = new_state;
......@@ -716,7 +719,7 @@ static void psmouse_connect(struct serio *serio, struct serio_driver *drv)
psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
psmouse->serio = serio;
psmouse->dev.private = psmouse;
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
serio->private = psmouse;
if (serio_open(serio, drv)) {
......@@ -756,6 +759,8 @@ static void psmouse_connect(struct serio *serio, struct serio_driver *drv)
printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys);
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
psmouse_initialize(psmouse);
if (parent && parent->pt_activate)
......@@ -795,7 +800,7 @@ static int psmouse_reconnect(struct serio *serio)
return -1;
}
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
if (psmouse->reconnect) {
if (psmouse->reconnect(psmouse))
......@@ -807,6 +812,8 @@ static int psmouse_reconnect(struct serio *serio)
/* ok, the device type (and capabilities) match the old one,
* we can continue using it, complete intialization
*/
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
psmouse_initialize(psmouse);
if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU)
......
......@@ -17,16 +17,18 @@
#define PSMOUSE_RET_ACK 0xfa
#define PSMOUSE_RET_NAK 0xfe
/* psmouse states */
#define PSMOUSE_CMD_MODE 0
#define PSMOUSE_ACTIVATED 1
#define PSMOUSE_IGNORE 2
#define PSMOUSE_FLAG_ACK 0 /* Waiting for ACK/NAK */
#define PSMOUSE_FLAG_CMD 1 /* Waiting for command to finish */
#define PSMOUSE_FLAG_CMD1 2 /* First byte of command response */
#define PSMOUSE_FLAG_ID 3 /* First byte is not keyboard ID */
enum psmouse_state {
PSMOUSE_IGNORE,
PSMOUSE_INITIALIZING,
PSMOUSE_CMD_MODE,
PSMOUSE_ACTIVATED,
};
/* psmouse protocol handler return codes */
typedef enum {
PSMOUSE_BAD_DATA,
......@@ -48,7 +50,7 @@ struct psmouse {
unsigned char model;
unsigned long last;
unsigned long out_of_sync;
unsigned char state;
enum psmouse_state state;
unsigned char nak;
char error;
char devname[64];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment