/[linux-patches]/genpatches-2.6/tags/3.0-30/2615_Input-ALPS-Remove-assumptions-about-packet-size.patch
Gentoo

Contents of /genpatches-2.6/tags/3.0-30/2615_Input-ALPS-Remove-assumptions-about-packet-size.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2206 - (show annotations) (download)
Mon Sep 17 18:58:14 2012 UTC (22 months, 1 week ago) by mpagano
File size: 2715 byte(s)
3.0-30 release
1 From 01b502f4af1fb4c3f1006a48c97da69ca48e04c7 Mon Sep 17 00:00:00 2001
2 From: Seth Forshee <seth.forshee@canonical.com>
3 Date: Wed, 14 Sep 2011 11:40:38 -0500
4 Subject: [PATCH 4/8] Input: ALPS - Remove assumptions about packet size
5
6 In preparation for version 4 protocol support, which has 8-byte
7 data packets, remove all hard-coded assumptions about packet size
8 and use psmouse->pktsize instead.
9
10 Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
11 ---
12 drivers/input/mouse/alps.c | 27 ++++++++++++++++++---------
13 1 files changed, 18 insertions(+), 9 deletions(-)
14
15 diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
16 index 572cb21..14d1f64 100644
17 --- a/drivers/input/mouse/alps.c
18 +++ b/drivers/input/mouse/alps.c
19 @@ -315,7 +315,7 @@ static void alps_flush_packet(unsigned long data)
20
21 serio_pause_rx(psmouse->ps2dev.serio);
22
23 - if (psmouse->pktcnt == 6) {
24 + if (psmouse->pktcnt == psmouse->pktsize) {
25
26 /*
27 * We did not any more data in reasonable amount of time.
28 @@ -365,15 +365,15 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
29 return PSMOUSE_BAD_DATA;
30 }
31
32 - /* Bytes 2 - 6 should have 0 in the highest bit */
33 - if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 &&
34 + /* Bytes 2 - pktsize should have 0 in the highest bit */
35 + if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize &&
36 (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
37 dbg("refusing packet[%i] = %x\n",
38 psmouse->pktcnt - 1, psmouse->packet[psmouse->pktcnt - 1]);
39 return PSMOUSE_BAD_DATA;
40 }
41
42 - if (psmouse->pktcnt == 6) {
43 + if (psmouse->pktcnt == psmouse->pktsize) {
44 alps_process_packet(psmouse);
45 return PSMOUSE_FULL_PACKET;
46 }
47 @@ -531,8 +531,13 @@ static int alps_tap_mode(struct psmouse *psmouse, int enable)
48 static int alps_poll(struct psmouse *psmouse)
49 {
50 struct alps_data *priv = psmouse->private;
51 - unsigned char buf[6];
52 + unsigned char *buf;
53 bool poll_failed;
54 + int ret = -1;
55 +
56 + buf = kmalloc(psmouse->pktsize, GFP_KERNEL);
57 + if (!buf)
58 + return -1;
59
60 if (priv->i->flags & ALPS_PASS)
61 alps_passthrough_mode(psmouse, true);
62 @@ -544,18 +549,22 @@ static int alps_poll(struct psmouse *psmouse)
63 alps_passthrough_mode(psmouse, false);
64
65 if (poll_failed || (buf[0] & priv->i->mask0) != priv->i->byte0)
66 - return -1;
67 + goto out;
68
69 if ((psmouse->badbyte & 0xc8) == 0x08) {
70 /*
71 * Poll the track stick ...
72 */
73 if (ps2_command(&psmouse->ps2dev, buf, PSMOUSE_CMD_POLL | (3 << 8)))
74 - return -1;
75 + goto out;
76 }
77
78 - memcpy(psmouse->packet, buf, sizeof(buf));
79 - return 0;
80 + memcpy(psmouse->packet, buf, psmouse->pktsize);
81 + ret = 0;
82 +
83 +out:
84 + kfree(buf);
85 + return ret;
86 }
87
88 static int alps_hw_init(struct psmouse *psmouse)
89 --
90 1.7.4.1

  ViewVC Help
Powered by ViewVC 1.1.20