Input: ALPS - remove assumptions about packet size
authorSeth Forshee <seth.forshee@canonical.com>
Tue, 8 Nov 2011 03:53:30 +0000 (19:53 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 8 Nov 2011 06:22:10 +0000 (22:22 -0800)
In preparation for version 4 protocol support, which has 8-byte
data packets, remove all hard-coded assumptions about packet size
and use psmouse->pktsize instead.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/mouse/alps.c

index 77b776d993773bc16ccf137026a4c5b3afc20462..44a0a712aaa27156a276e25b9d08dd5bccdb8949 100644 (file)
@@ -308,7 +308,7 @@ static void alps_flush_packet(unsigned long data)
 
        serio_pause_rx(psmouse->ps2dev.serio);
 
-       if (psmouse->pktcnt == 6) {
+       if (psmouse->pktcnt == psmouse->pktsize) {
 
                /*
                 * We did not any more data in reasonable amount of time.
@@ -359,8 +359,8 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
                return PSMOUSE_BAD_DATA;
        }
 
-       /* Bytes 2 - 6 should have 0 in the highest bit */
-       if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 &&
+       /* Bytes 2 - pktsize should have 0 in the highest bit */
+       if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize &&
            (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
                psmouse_dbg(psmouse, "refusing packet[%i] = %x\n",
                            psmouse->pktcnt - 1,
@@ -368,7 +368,7 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
                return PSMOUSE_BAD_DATA;
        }
 
-       if (psmouse->pktcnt == 6) {
+       if (psmouse->pktcnt == psmouse->pktsize) {
                alps_process_packet(psmouse);
                return PSMOUSE_FULL_PACKET;
        }
@@ -529,7 +529,7 @@ static int alps_tap_mode(struct psmouse *psmouse, int enable)
 static int alps_poll(struct psmouse *psmouse)
 {
        struct alps_data *priv = psmouse->private;
-       unsigned char buf[6];
+       unsigned char buf[sizeof(psmouse->packet)];
        bool poll_failed;
 
        if (priv->i->flags & ALPS_PASS)