Skip to content

Commit

Permalink
Input: vmmouse - fix absolute device registration
Browse files Browse the repository at this point in the history
We should set device's capabilities first, and then register it,
otherwise various handlers already present in the kernel will not be
able to connect to the device.

Reported-by: Lauri Kasanen <[email protected]>
Cc: [email protected]
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
dtor committed Jan 28, 2016
1 parent 015bb5e commit d4f1b06
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/input/mouse/vmmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,6 @@ int vmmouse_init(struct psmouse *psmouse)
priv->abs_dev = abs_dev;
psmouse->private = priv;

input_set_capability(rel_dev, EV_REL, REL_WHEEL);

/* Set up and register absolute device */
snprintf(priv->phys, sizeof(priv->phys), "%s/input1",
psmouse->ps2dev.serio->phys);
Expand All @@ -475,10 +473,6 @@ int vmmouse_init(struct psmouse *psmouse)
abs_dev->id.version = psmouse->model;
abs_dev->dev.parent = &psmouse->ps2dev.serio->dev;

error = input_register_device(priv->abs_dev);
if (error)
goto init_fail;

/* Set absolute device capabilities */
input_set_capability(abs_dev, EV_KEY, BTN_LEFT);
input_set_capability(abs_dev, EV_KEY, BTN_RIGHT);
Expand All @@ -488,6 +482,13 @@ int vmmouse_init(struct psmouse *psmouse)
input_set_abs_params(abs_dev, ABS_X, 0, VMMOUSE_MAX_X, 0, 0);
input_set_abs_params(abs_dev, ABS_Y, 0, VMMOUSE_MAX_Y, 0, 0);

error = input_register_device(priv->abs_dev);
if (error)
goto init_fail;

/* Add wheel capability to the relative device */
input_set_capability(rel_dev, EV_REL, REL_WHEEL);

psmouse->protocol_handler = vmmouse_process_byte;
psmouse->disconnect = vmmouse_disconnect;
psmouse->reconnect = vmmouse_reconnect;
Expand Down

0 comments on commit d4f1b06

Please sign in to comment.