Commit 9d554f34 authored by Hans de Goede's avatar Hans de Goede Committed by Luis Henriques

Input: psmouse - add psmouse_matches_pnp_id helper function

commit 2c75ada6 upstream.

The matches_pnp_id function from the synaptics driver is useful for other
drivers too. Make it a generic psmouse helper function.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
[ luis: 3.16-stable prereq for:
  8b04baba "Input: synaptics - split synaptics_resolution(), query first" ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 4272f954
...@@ -462,6 +462,20 @@ static int psmouse_poll(struct psmouse *psmouse) ...@@ -462,6 +462,20 @@ static int psmouse_poll(struct psmouse *psmouse)
PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)); PSMOUSE_CMD_POLL | (psmouse->pktsize << 8));
} }
/*
* psmouse_matches_pnp_id - check if psmouse matches one of the passed in ids.
*/
bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[])
{
int i;
if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4))
for (i = 0; ids[i]; i++)
if (strstr(psmouse->ps2dev.serio->firmware_id, ids[i]))
return true;
return false;
}
/* /*
* Genius NetMouse magic init. * Genius NetMouse magic init.
......
...@@ -108,6 +108,7 @@ void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); ...@@ -108,6 +108,7 @@ void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse); psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse);
int psmouse_activate(struct psmouse *psmouse); int psmouse_activate(struct psmouse *psmouse);
int psmouse_deactivate(struct psmouse *psmouse); int psmouse_deactivate(struct psmouse *psmouse);
bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[]);
struct psmouse_attribute { struct psmouse_attribute {
struct device_attribute dattr; struct device_attribute dattr;
......
...@@ -188,18 +188,6 @@ static const char * const topbuttonpad_pnp_ids[] = { ...@@ -188,18 +188,6 @@ static const char * const topbuttonpad_pnp_ids[] = {
NULL NULL
}; };
static bool matches_pnp_id(struct psmouse *psmouse, const char * const ids[])
{
int i;
if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4))
for (i = 0; ids[i]; i++)
if (strstr(psmouse->ps2dev.serio->firmware_id, ids[i]))
return true;
return false;
}
/***************************************************************************** /*****************************************************************************
* Synaptics communications functions * Synaptics communications functions
****************************************************************************/ ****************************************************************************/
...@@ -365,7 +353,8 @@ static int synaptics_resolution(struct psmouse *psmouse) ...@@ -365,7 +353,8 @@ static int synaptics_resolution(struct psmouse *psmouse)
} }
for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) { for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
if (matches_pnp_id(psmouse, min_max_pnpid_table[i].pnp_ids)) { if (psmouse_matches_pnp_id(psmouse,
min_max_pnpid_table[i].pnp_ids)) {
priv->x_min = min_max_pnpid_table[i].x_min; priv->x_min = min_max_pnpid_table[i].x_min;
priv->x_max = min_max_pnpid_table[i].x_max; priv->x_max = min_max_pnpid_table[i].x_max;
priv->y_min = min_max_pnpid_table[i].y_min; priv->y_min = min_max_pnpid_table[i].y_min;
...@@ -1448,7 +1437,7 @@ static void set_input_params(struct psmouse *psmouse, ...@@ -1448,7 +1437,7 @@ static void set_input_params(struct psmouse *psmouse,
if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) { if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
__set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
if (matches_pnp_id(psmouse, topbuttonpad_pnp_ids)) if (psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids))
__set_bit(INPUT_PROP_TOPBUTTONPAD, dev->propbit); __set_bit(INPUT_PROP_TOPBUTTONPAD, dev->propbit);
/* Clickpads report only left button */ /* Clickpads report only left button */
__clear_bit(BTN_RIGHT, dev->keybit); __clear_bit(BTN_RIGHT, dev->keybit);
......
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