From 08be954b7a7de6742d3d47e4dc20e3b086410761 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Tue, 2 Jan 2018 12:03:02 -0800 Subject: Input: psmouse - move sliced command implementation to libps2 In preparation to adding some debugging statements to PS/2 control sequences let's move psmouse_sliced_command() into libps2 and rename it to ps2_sliced_command(). Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/synaptics.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/input/mouse/synaptics.c') diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index cd9f61cb3fc6..89ab77a211b5 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -84,7 +84,7 @@ static int synaptics_mode_cmd(struct psmouse *psmouse, u8 mode) u8 param[1]; int error; - error = psmouse_sliced_command(psmouse, mode); + error = ps2_sliced_command(&psmouse->ps2dev, mode); if (error) return error; @@ -190,7 +190,7 @@ static int synaptics_send_cmd(struct psmouse *psmouse, u8 cmd, u8 *param) { int error; - error = psmouse_sliced_command(psmouse, cmd); + error = ps2_sliced_command(&psmouse->ps2dev, cmd); if (error) return error; @@ -547,7 +547,7 @@ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) static u8 param = 0xc8; int error; - error = psmouse_sliced_command(psmouse, SYN_QUE_MODEL); + error = ps2_sliced_command(&psmouse->ps2dev, SYN_QUE_MODEL); if (error) return error; @@ -614,7 +614,7 @@ static int synaptics_pt_write(struct serio *serio, u8 c) u8 rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */ int error; - error = psmouse_sliced_command(parent, c); + error = ps2_sliced_command(&parent->ps2dev, c); if (error) return error; -- cgit v1.2.3-59-g8ed1b From 29aa619408adc1f88745feed02265acfbc0b8fea Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 3 Apr 2017 16:37:24 -0700 Subject: Input: synaptics - switch to using input_set_capability Instead of manipulating capability bits directly, use input_set_capability(). Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/synaptics.c | 49 ++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'drivers/input/mouse/synaptics.c') diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index 3d2e23a0ae39..feb9c04d0eae 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -1235,25 +1235,31 @@ static void set_input_params(struct psmouse *psmouse, struct synaptics_device_info *info = &priv->info; int i; + /* Reset default psmouse capabilities */ + __clear_bit(EV_REL, dev->evbit); + bitmap_zero(dev->relbit, REL_CNT); + bitmap_zero(dev->keybit, KEY_CNT); + /* Things that apply to both modes */ __set_bit(INPUT_PROP_POINTER, dev->propbit); - __set_bit(EV_KEY, dev->evbit); - __set_bit(BTN_LEFT, dev->keybit); - __set_bit(BTN_RIGHT, dev->keybit); - if (SYN_CAP_MIDDLE_BUTTON(info->capabilities)) - __set_bit(BTN_MIDDLE, dev->keybit); + input_set_capability(dev, EV_KEY, BTN_LEFT); + + /* Clickpads report only left button */ + if (!SYN_CAP_CLICKPAD(info->ext_cap_0c)) { + input_set_capability(dev, EV_KEY, BTN_RIGHT); + if (SYN_CAP_MIDDLE_BUTTON(info->capabilities)) + input_set_capability(dev, EV_KEY, BTN_MIDDLE); + } if (!priv->absolute_mode) { /* Relative mode */ - __set_bit(EV_REL, dev->evbit); - __set_bit(REL_X, dev->relbit); - __set_bit(REL_Y, dev->relbit); + input_set_capability(dev, EV_REL, REL_X); + input_set_capability(dev, EV_REL, REL_Y); return; } /* Absolute mode */ - __set_bit(EV_ABS, dev->evbit); set_abs_position_params(dev, &priv->info, ABS_X, ABS_Y); input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); @@ -1268,8 +1274,8 @@ static void set_input_params(struct psmouse *psmouse, input_mt_init_slots(dev, 2, INPUT_MT_POINTER | INPUT_MT_TRACK); /* Image sensors can signal 4 and 5 finger clicks */ - __set_bit(BTN_TOOL_QUADTAP, dev->keybit); - __set_bit(BTN_TOOL_QUINTTAP, dev->keybit); + input_set_capability(dev, EV_KEY, BTN_TOOL_QUADTAP); + input_set_capability(dev, EV_KEY, BTN_TOOL_QUINTTAP); } else if (SYN_CAP_ADV_GESTURE(info->ext_cap_0c)) { set_abs_position_params(dev, info, ABS_MT_POSITION_X, ABS_MT_POSITION_Y); @@ -1296,36 +1302,29 @@ static void set_input_params(struct psmouse *psmouse, if (SYN_CAP_PALMDETECT(info->capabilities)) input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0); - __set_bit(BTN_TOUCH, dev->keybit); - __set_bit(BTN_TOOL_FINGER, dev->keybit); + input_set_capability(dev, EV_KEY, BTN_TOUCH); + input_set_capability(dev, EV_KEY, BTN_TOOL_FINGER); if (synaptics_has_multifinger(priv)) { - __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit); - __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit); + input_set_capability(dev, EV_KEY, BTN_TOOL_DOUBLETAP); + input_set_capability(dev, EV_KEY, BTN_TOOL_TRIPLETAP); } if (SYN_CAP_FOUR_BUTTON(info->capabilities) || SYN_CAP_MIDDLE_BUTTON(info->capabilities)) { - __set_bit(BTN_FORWARD, dev->keybit); - __set_bit(BTN_BACK, dev->keybit); + input_set_capability(dev, EV_KEY, BTN_FORWARD); + input_set_capability(dev, EV_KEY, BTN_BACK); } if (!SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10)) for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(info->ext_cap); i++) - __set_bit(BTN_0 + i, dev->keybit); - - __clear_bit(EV_REL, dev->evbit); - __clear_bit(REL_X, dev->relbit); - __clear_bit(REL_Y, dev->relbit); + input_set_capability(dev, EV_KEY, BTN_0 + i); if (SYN_CAP_CLICKPAD(info->ext_cap_0c)) { __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); if (psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids) && !SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10)) __set_bit(INPUT_PROP_TOPBUTTONPAD, dev->propbit); - /* Clickpads report only left button */ - __clear_bit(BTN_RIGHT, dev->keybit); - __clear_bit(BTN_MIDDLE, dev->keybit); } } -- cgit v1.2.3-59-g8ed1b From cdc2466df40f26af60f6b18123069bd52336a80c Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 3 Apr 2017 16:54:04 -0700 Subject: Input: synaptics - handle errors from input_mt_init_slots() input_mt_init_slots() may fail, we need to handle this condition. Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/synaptics.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'drivers/input/mouse/synaptics.c') diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index feb9c04d0eae..dcb8e0cfaa1a 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -1228,12 +1228,13 @@ static void set_abs_position_params(struct input_dev *dev, input_abs_set_res(dev, y_code, info->y_res); } -static void set_input_params(struct psmouse *psmouse, - struct synaptics_data *priv) +static int set_input_params(struct psmouse *psmouse, + struct synaptics_data *priv) { struct input_dev *dev = psmouse->dev; struct synaptics_device_info *info = &priv->info; int i; + int error; /* Reset default psmouse capabilities */ __clear_bit(EV_REL, dev->evbit); @@ -1256,7 +1257,7 @@ static void set_input_params(struct psmouse *psmouse, /* Relative mode */ input_set_capability(dev, EV_REL, REL_X); input_set_capability(dev, EV_REL, REL_Y); - return; + return 0; } /* Absolute mode */ @@ -1271,7 +1272,11 @@ static void set_input_params(struct psmouse *psmouse, ABS_MT_POSITION_X, ABS_MT_POSITION_Y); /* Image sensors can report per-contact pressure */ input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0); - input_mt_init_slots(dev, 2, INPUT_MT_POINTER | INPUT_MT_TRACK); + + error = input_mt_init_slots(dev, 2, + INPUT_MT_POINTER | INPUT_MT_TRACK); + if (error) + return error; /* Image sensors can signal 4 and 5 finger clicks */ input_set_capability(dev, EV_KEY, BTN_TOOL_QUADTAP); @@ -1283,10 +1288,13 @@ static void set_input_params(struct psmouse *psmouse, * Profile sensor in CR-48 tracks contacts reasonably well, * other non-image sensors with AGM use semi-mt. */ - input_mt_init_slots(dev, 2, - INPUT_MT_POINTER | - (cr48_profile_sensor ? - INPUT_MT_TRACK : INPUT_MT_SEMI_MT)); + error = input_mt_init_slots(dev, 2, + INPUT_MT_POINTER | + (cr48_profile_sensor ? + INPUT_MT_TRACK : + INPUT_MT_SEMI_MT)); + if (error) + return error; /* * For semi-mt devices we send ABS_X/Y ourselves instead of @@ -1326,6 +1334,8 @@ static void set_input_params(struct psmouse *psmouse, !SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10)) __set_bit(INPUT_PROP_TOPBUTTONPAD, dev->propbit); } + + return 0; } static ssize_t synaptics_show_disable_gesture(struct psmouse *psmouse, @@ -1563,7 +1573,12 @@ static int synaptics_init_ps2(struct psmouse *psmouse, info->capabilities, info->ext_cap, info->ext_cap_0c, info->ext_cap_10, info->board_id, info->firmware_id); - set_input_params(psmouse, priv); + err = set_input_params(psmouse, priv); + if (err) { + psmouse_err(psmouse, + "failed to set up capabilities: %d\n", err); + goto init_fail; + } /* * Encode touchpad model so that it can be used to set -- cgit v1.2.3-59-g8ed1b