diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-07-15 02:51:56 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-07-15 02:51:56 -0400 |
commit | 463a4f76a79bce00ca8964e0b2ebf7f10f376965 (patch) | |
tree | 333f5dad75a76921ae88657377619a0b14ef1f67 | |
parent | 7b4019d04895de7407c9989895c3664c24ed01f7 (diff) |
Input: i8042 - don't use negation to mark AUX data
Currently i8042_command() negates data coming from the AUX port
of keyboard controller; this is not a very reliable indicator.
Change i8042_command() to fail if response to I8042_CMD_AUX_LOOP
is not coming from AUX channel and get rid of negation.
Based on patch by Vojtech Pavlik.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/input/serio/i8042.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index a9bf549c8dc5..708a1d3beab9 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
@@ -100,7 +100,7 @@ struct i8042_port { | |||
100 | static struct i8042_port i8042_ports[I8042_NUM_PORTS] = { | 100 | static struct i8042_port i8042_ports[I8042_NUM_PORTS] = { |
101 | { | 101 | { |
102 | .disable = I8042_CTR_KBDDIS, | 102 | .disable = I8042_CTR_KBDDIS, |
103 | .irqen = I8042_CTR_KBDINT, | 103 | .irqen = I8042_CTR_KBDINT, |
104 | .mux = -1, | 104 | .mux = -1, |
105 | .name = "KBD", | 105 | .name = "KBD", |
106 | }, | 106 | }, |
@@ -191,41 +191,45 @@ static int i8042_flush(void) | |||
191 | static int i8042_command(unsigned char *param, int command) | 191 | static int i8042_command(unsigned char *param, int command) |
192 | { | 192 | { |
193 | unsigned long flags; | 193 | unsigned long flags; |
194 | int retval = 0, i = 0; | 194 | int i, retval, auxerr = 0; |
195 | 195 | ||
196 | if (i8042_noloop && command == I8042_CMD_AUX_LOOP) | 196 | if (i8042_noloop && command == I8042_CMD_AUX_LOOP) |
197 | return -1; | 197 | return -1; |
198 | 198 | ||
199 | spin_lock_irqsave(&i8042_lock, flags); | 199 | spin_lock_irqsave(&i8042_lock, flags); |
200 | 200 | ||
201 | retval = i8042_wait_write(); | 201 | if ((retval = i8042_wait_write())) |
202 | if (!retval) { | 202 | goto out; |
203 | dbg("%02x -> i8042 (command)", command & 0xff); | 203 | |
204 | i8042_write_command(command & 0xff); | 204 | dbg("%02x -> i8042 (command)", command & 0xff); |
205 | i8042_write_command(command & 0xff); | ||
206 | |||
207 | for (i = 0; i < ((command >> 12) & 0xf); i++) { | ||
208 | if ((retval = i8042_wait_write())) | ||
209 | goto out; | ||
210 | dbg("%02x -> i8042 (parameter)", param[i]); | ||
211 | i8042_write_data(param[i]); | ||
205 | } | 212 | } |
206 | 213 | ||
207 | if (!retval) | 214 | for (i = 0; i < ((command >> 8) & 0xf); i++) { |
208 | for (i = 0; i < ((command >> 12) & 0xf); i++) { | 215 | if ((retval = i8042_wait_read())) |
209 | if ((retval = i8042_wait_write())) break; | 216 | goto out; |
210 | dbg("%02x -> i8042 (parameter)", param[i]); | ||
211 | i8042_write_data(param[i]); | ||
212 | } | ||
213 | 217 | ||
214 | if (!retval) | 218 | if (command == I8042_CMD_AUX_LOOP && |
215 | for (i = 0; i < ((command >> 8) & 0xf); i++) { | 219 | !(i8042_read_status() & I8042_STR_AUXDATA)) { |
216 | if ((retval = i8042_wait_read())) break; | 220 | retval = auxerr = -1; |
217 | if (i8042_read_status() & I8042_STR_AUXDATA) | 221 | goto out; |
218 | param[i] = ~i8042_read_data(); | ||
219 | else | ||
220 | param[i] = i8042_read_data(); | ||
221 | dbg("%02x <- i8042 (return)", param[i]); | ||
222 | } | 222 | } |
223 | 223 | ||
224 | spin_unlock_irqrestore(&i8042_lock, flags); | 224 | param[i] = i8042_read_data(); |
225 | dbg("%02x <- i8042 (return)", param[i]); | ||
226 | } | ||
225 | 227 | ||
226 | if (retval) | 228 | if (retval) |
227 | dbg(" -- i8042 (timeout)"); | 229 | dbg(" -- i8042 (%s)", auxerr ? "auxerr" : "timeout"); |
228 | 230 | ||
231 | out: | ||
232 | spin_unlock_irqrestore(&i8042_lock, flags); | ||
229 | return retval; | 233 | return retval; |
230 | } | 234 | } |
231 | 235 | ||
@@ -507,17 +511,17 @@ static int i8042_set_mux_mode(unsigned int mode, unsigned char *mux_version) | |||
507 | */ | 511 | */ |
508 | 512 | ||
509 | param = 0xf0; | 513 | param = 0xf0; |
510 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != 0x0f) | 514 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != 0xf0) |
511 | return -1; | 515 | return -1; |
512 | param = mode ? 0x56 : 0xf6; | 516 | param = mode ? 0x56 : 0xf6; |
513 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != (mode ? 0xa9 : 0x09)) | 517 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != (mode ? 0x56 : 0xf6)) |
514 | return -1; | 518 | return -1; |
515 | param = mode ? 0xa4 : 0xa5; | 519 | param = mode ? 0xa4 : 0xa5; |
516 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param == (mode ? 0x5b : 0x5a)) | 520 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param == (mode ? 0xa4 : 0xa5)) |
517 | return -1; | 521 | return -1; |
518 | 522 | ||
519 | if (mux_version) | 523 | if (mux_version) |
520 | *mux_version = ~param; | 524 | *mux_version = param; |
521 | 525 | ||
522 | return 0; | 526 | return 0; |
523 | } | 527 | } |
@@ -619,7 +623,7 @@ static int __init i8042_check_aux(void) | |||
619 | */ | 623 | */ |
620 | 624 | ||
621 | param = 0x5a; | 625 | param = 0x5a; |
622 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != 0xa5) { | 626 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != 0x5a) { |
623 | 627 | ||
624 | /* | 628 | /* |
625 | * External connection test - filters out AT-soldered PS/2 i8042's | 629 | * External connection test - filters out AT-soldered PS/2 i8042's |
@@ -630,7 +634,7 @@ static int __init i8042_check_aux(void) | |||
630 | */ | 634 | */ |
631 | 635 | ||
632 | if (i8042_command(¶m, I8042_CMD_AUX_TEST) | 636 | if (i8042_command(¶m, I8042_CMD_AUX_TEST) |
633 | || (param && param != 0xfa && param != 0xff)) | 637 | || (param && param != 0xfa && param != 0xff)) |
634 | return -1; | 638 | return -1; |
635 | } | 639 | } |
636 | 640 | ||