aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/serio/libps2.c20
-rw-r--r--include/linux/libps2.h2
2 files changed, 18 insertions, 4 deletions
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index 2b304c22c200..67248c31e19a 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -262,9 +262,17 @@ int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data)
262 break; 262 break;
263 263
264 case PS2_RET_NAK: 264 case PS2_RET_NAK:
265 ps2dev->nak = 1; 265 ps2dev->flags |= PS2_FLAG_NAK;
266 ps2dev->nak = PS2_RET_NAK;
266 break; 267 break;
267 268
269 case PS2_RET_ERR:
270 if (ps2dev->flags & PS2_FLAG_NAK) {
271 ps2dev->flags &= ~PS2_FLAG_NAK;
272 ps2dev->nak = PS2_RET_ERR;
273 break;
274 }
275
268 /* 276 /*
269 * Workaround for mice which don't ACK the Get ID command. 277 * Workaround for mice which don't ACK the Get ID command.
270 * These are valid mouse IDs that we recognize. 278 * These are valid mouse IDs that we recognize.
@@ -282,8 +290,11 @@ int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data)
282 } 290 }
283 291
284 292
285 if (!ps2dev->nak && ps2dev->cmdcnt) 293 if (!ps2dev->nak) {
286 ps2dev->flags |= PS2_FLAG_CMD | PS2_FLAG_CMD1; 294 ps2dev->flags &= ~PS2_FLAG_NAK;
295 if (ps2dev->cmdcnt)
296 ps2dev->flags |= PS2_FLAG_CMD | PS2_FLAG_CMD1;
297 }
287 298
288 ps2dev->flags &= ~PS2_FLAG_ACK; 299 ps2dev->flags &= ~PS2_FLAG_ACK;
289 wake_up(&ps2dev->wait); 300 wake_up(&ps2dev->wait);
@@ -329,6 +340,7 @@ void ps2_cmd_aborted(struct ps2dev *ps2dev)
329 if (ps2dev->flags & (PS2_FLAG_ACK | PS2_FLAG_CMD)) 340 if (ps2dev->flags & (PS2_FLAG_ACK | PS2_FLAG_CMD))
330 wake_up(&ps2dev->wait); 341 wake_up(&ps2dev->wait);
331 342
332 ps2dev->flags = 0; 343 /* reset all flags except last nack */
344 ps2dev->flags &= PS2_FLAG_NAK;
333} 345}
334EXPORT_SYMBOL(ps2_cmd_aborted); 346EXPORT_SYMBOL(ps2_cmd_aborted);
diff --git a/include/linux/libps2.h b/include/linux/libps2.h
index afc413369101..b94534b7e266 100644
--- a/include/linux/libps2.h
+++ b/include/linux/libps2.h
@@ -18,11 +18,13 @@
18#define PS2_RET_ID 0x00 18#define PS2_RET_ID 0x00
19#define PS2_RET_ACK 0xfa 19#define PS2_RET_ACK 0xfa
20#define PS2_RET_NAK 0xfe 20#define PS2_RET_NAK 0xfe
21#define PS2_RET_ERR 0xfc
21 22
22#define PS2_FLAG_ACK 1 /* Waiting for ACK/NAK */ 23#define PS2_FLAG_ACK 1 /* Waiting for ACK/NAK */
23#define PS2_FLAG_CMD 2 /* Waiting for command to finish */ 24#define PS2_FLAG_CMD 2 /* Waiting for command to finish */
24#define PS2_FLAG_CMD1 4 /* Waiting for the first byte of command response */ 25#define PS2_FLAG_CMD1 4 /* Waiting for the first byte of command response */
25#define PS2_FLAG_WAITID 8 /* Command execiting is GET ID */ 26#define PS2_FLAG_WAITID 8 /* Command execiting is GET ID */
27#define PS2_FLAG_NAK 16 /* Last transmission was NAKed */
26 28
27struct ps2dev { 29struct ps2dev {
28 struct serio *serio; 30 struct serio *serio;