Commit a45857d1 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: when changing psmouse state (activated, ignore) use srio_pause_rx/

       serio_continue_rx so it will not fight with the interrupt handler
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 91cac0b0
...@@ -625,6 +625,21 @@ static void psmouse_initialize(struct psmouse *psmouse) ...@@ -625,6 +625,21 @@ static void psmouse_initialize(struct psmouse *psmouse)
psmouse_command(psmouse, param, PSMOUSE_CMD_SETSTREAM); psmouse_command(psmouse, param, PSMOUSE_CMD_SETSTREAM);
} }
/*
* psmouse_set_state() sets new psmouse state and resets all flags and
* counters while holding serio lock so fighting with interrupt handler
* is not a concern.
*/
static void psmouse_set_state(struct psmouse *psmouse, unsigned char new_state)
{
serio_pause_rx(psmouse->serio);
psmouse->state = new_state;
psmouse->pktcnt = psmouse->cmdcnt = psmouse->out_of_sync = 0;
psmouse->flags = 0;
serio_continue_rx(psmouse->serio);
}
/* /*
* psmouse_activate() enables the mouse so that we get motion reports from it. * psmouse_activate() enables the mouse so that we get motion reports from it.
*/ */
...@@ -634,7 +649,7 @@ static void psmouse_activate(struct psmouse *psmouse) ...@@ -634,7 +649,7 @@ static void psmouse_activate(struct psmouse *psmouse)
if (psmouse_command(psmouse, NULL, PSMOUSE_CMD_ENABLE)) if (psmouse_command(psmouse, NULL, PSMOUSE_CMD_ENABLE))
printk(KERN_WARNING "psmouse.c: Failed to enable mouse on %s\n", psmouse->serio->phys); printk(KERN_WARNING "psmouse.c: Failed to enable mouse on %s\n", psmouse->serio->phys);
psmouse->state = PSMOUSE_ACTIVATED; psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
} }
/* /*
...@@ -657,7 +672,7 @@ static void psmouse_disconnect(struct serio *serio) ...@@ -657,7 +672,7 @@ static void psmouse_disconnect(struct serio *serio)
struct psmouse *psmouse, *parent; struct psmouse *psmouse, *parent;
psmouse = serio->private; psmouse = serio->private;
psmouse->state = PSMOUSE_CMD_MODE; psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) { if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
parent = serio->parent->private; parent = serio->parent->private;
...@@ -668,7 +683,7 @@ static void psmouse_disconnect(struct serio *serio) ...@@ -668,7 +683,7 @@ static void psmouse_disconnect(struct serio *serio)
if (psmouse->disconnect) if (psmouse->disconnect)
psmouse->disconnect(psmouse); psmouse->disconnect(psmouse);
psmouse->state = PSMOUSE_IGNORE; psmouse_set_state(psmouse, PSMOUSE_IGNORE);
input_unregister_device(&psmouse->dev); input_unregister_device(&psmouse->dev);
serio_close(serio); serio_close(serio);
...@@ -699,9 +714,9 @@ static void psmouse_connect(struct serio *serio, struct serio_driver *drv) ...@@ -699,9 +714,9 @@ static void psmouse_connect(struct serio *serio, struct serio_driver *drv)
psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
psmouse->state = PSMOUSE_CMD_MODE;
psmouse->serio = serio; psmouse->serio = serio;
psmouse->dev.private = psmouse; psmouse->dev.private = psmouse;
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
serio->private = psmouse; serio->private = psmouse;
if (serio_open(serio, drv)) { if (serio_open(serio, drv)) {
...@@ -780,12 +795,7 @@ static int psmouse_reconnect(struct serio *serio) ...@@ -780,12 +795,7 @@ static int psmouse_reconnect(struct serio *serio)
return -1; return -1;
} }
psmouse->state = PSMOUSE_CMD_MODE; psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
clear_bit(PSMOUSE_FLAG_ACK, &psmouse->flags);
clear_bit(PSMOUSE_FLAG_CMD, &psmouse->flags);
psmouse->pktcnt = psmouse->out_of_sync = 0;
if (psmouse->reconnect) { if (psmouse->reconnect) {
if (psmouse->reconnect(psmouse)) if (psmouse->reconnect(psmouse))
......
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