diff options
author | Jan-Benedict Glaw <jbglaw@lug-owl.de> | 2005-11-02 22:53:11 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-11-02 22:53:11 -0500 |
commit | 0aeafa77558fc1b44b0f39a4d9e5bd9316420788 (patch) | |
tree | 521696284eab46eda650ea2bc9c767a43209c90a /drivers/input/keyboard/lkkbd.c | |
parent | 14a48b444420908cf8f87be12f5c94fb9ab16673 (diff) |
Input: lkkbd - miscellaneous fixes
* Hide debugging code into #ifdef, which allows to simplify
the large switch statement
* Update macros to not reference variables not given as
arguments
Signed-off-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard/lkkbd.c')
-rw-r--r-- | drivers/input/keyboard/lkkbd.c | 101 |
1 files changed, 59 insertions, 42 deletions
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 9481132532d0..77c4d9669ad0 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c | |||
@@ -273,11 +273,11 @@ static lk_keycode_t lkkbd_keycode[LK_NUM_KEYCODES] = { | |||
273 | [0xfb] = KEY_APOSTROPHE, | 273 | [0xfb] = KEY_APOSTROPHE, |
274 | }; | 274 | }; |
275 | 275 | ||
276 | #define CHECK_LED(LED, BITS) do { \ | 276 | #define CHECK_LED(LK, VAR_ON, VAR_OFF, LED, BITS) do { \ |
277 | if (test_bit (LED, lk->dev->led)) \ | 277 | if (test_bit (LED, (LK)->dev->led)) \ |
278 | leds_on |= BITS; \ | 278 | VAR_ON |= BITS; \ |
279 | else \ | 279 | else \ |
280 | leds_off |= BITS; \ | 280 | VAR_OFF |= BITS; \ |
281 | } while (0) | 281 | } while (0) |
282 | 282 | ||
283 | /* | 283 | /* |
@@ -298,6 +298,42 @@ struct lkkbd { | |||
298 | int ctrlclick_volume; | 298 | int ctrlclick_volume; |
299 | }; | 299 | }; |
300 | 300 | ||
301 | #ifdef LKKBD_DEBUG | ||
302 | /* | ||
303 | * Responses from the keyboard and mapping back to their names. | ||
304 | */ | ||
305 | static struct { | ||
306 | unsigned char value; | ||
307 | unsigned char *name; | ||
308 | } lk_response[] = { | ||
309 | #define RESPONSE(x) { .value = (x), .name = #x, } | ||
310 | RESPONSE (LK_STUCK_KEY), | ||
311 | RESPONSE (LK_SELFTEST_FAILED), | ||
312 | RESPONSE (LK_ALL_KEYS_UP), | ||
313 | RESPONSE (LK_METRONOME), | ||
314 | RESPONSE (LK_OUTPUT_ERROR), | ||
315 | RESPONSE (LK_INPUT_ERROR), | ||
316 | RESPONSE (LK_KBD_LOCKED), | ||
317 | RESPONSE (LK_KBD_TEST_MODE_ACK), | ||
318 | RESPONSE (LK_PREFIX_KEY_DOWN), | ||
319 | RESPONSE (LK_MODE_CHANGE_ACK), | ||
320 | RESPONSE (LK_RESPONSE_RESERVED), | ||
321 | #undef RESPONSE | ||
322 | }; | ||
323 | |||
324 | static unsigned char * | ||
325 | response_name (unsigned char value) | ||
326 | { | ||
327 | int i; | ||
328 | |||
329 | for (i = 0; i < ARRAY_SIZE (lk_response); i++) | ||
330 | if (lk_response[i].value == value) | ||
331 | return lk_response[i].name; | ||
332 | |||
333 | return "<unknown>"; | ||
334 | } | ||
335 | #endif /* LKKBD_DEBUG */ | ||
336 | |||
301 | /* | 337 | /* |
302 | * Calculate volume parameter byte for a given volume. | 338 | * Calculate volume parameter byte for a given volume. |
303 | */ | 339 | */ |
@@ -440,43 +476,24 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags, | |||
440 | input_report_key (lk->dev, lk->keycode[i], 0); | 476 | input_report_key (lk->dev, lk->keycode[i], 0); |
441 | input_sync (lk->dev); | 477 | input_sync (lk->dev); |
442 | break; | 478 | break; |
443 | case LK_METRONOME: | 479 | |
444 | DBG (KERN_INFO "Got LK_METRONOME and don't " | 480 | case 0x01: |
445 | "know how to handle...\n"); | 481 | DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n"); |
482 | lk->ignore_bytes = LK_NUM_IGNORE_BYTES; | ||
483 | lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data; | ||
484 | schedule_work (&lk->tq); | ||
446 | break; | 485 | break; |
486 | |||
487 | case LK_METRONOME: | ||
447 | case LK_OUTPUT_ERROR: | 488 | case LK_OUTPUT_ERROR: |
448 | DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't " | ||
449 | "know how to handle...\n"); | ||
450 | break; | ||
451 | case LK_INPUT_ERROR: | 489 | case LK_INPUT_ERROR: |
452 | DBG (KERN_INFO "Got LK_INPUT_ERROR and don't " | ||
453 | "know how to handle...\n"); | ||
454 | break; | ||
455 | case LK_KBD_LOCKED: | 490 | case LK_KBD_LOCKED: |
456 | DBG (KERN_INFO "Got LK_KBD_LOCKED and don't " | ||
457 | "know how to handle...\n"); | ||
458 | break; | ||
459 | case LK_KBD_TEST_MODE_ACK: | 491 | case LK_KBD_TEST_MODE_ACK: |
460 | DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't " | ||
461 | "know how to handle...\n"); | ||
462 | break; | ||
463 | case LK_PREFIX_KEY_DOWN: | 492 | case LK_PREFIX_KEY_DOWN: |
464 | DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't " | ||
465 | "know how to handle...\n"); | ||
466 | break; | ||
467 | case LK_MODE_CHANGE_ACK: | 493 | case LK_MODE_CHANGE_ACK: |
468 | DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored " | ||
469 | "it properly...\n"); | ||
470 | break; | ||
471 | case LK_RESPONSE_RESERVED: | 494 | case LK_RESPONSE_RESERVED: |
472 | DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't " | 495 | DBG (KERN_INFO "Got %s and don't know how to handle...\n", |
473 | "know how to handle...\n"); | 496 | response_name (data)); |
474 | break; | ||
475 | case 0x01: | ||
476 | DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n"); | ||
477 | lk->ignore_bytes = LK_NUM_IGNORE_BYTES; | ||
478 | lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data; | ||
479 | schedule_work (&lk->tq); | ||
480 | break; | 497 | break; |
481 | 498 | ||
482 | default: | 499 | default: |
@@ -509,10 +526,10 @@ lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code, | |||
509 | 526 | ||
510 | switch (type) { | 527 | switch (type) { |
511 | case EV_LED: | 528 | case EV_LED: |
512 | CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK); | 529 | CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK); |
513 | CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE); | 530 | CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE); |
514 | CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK); | 531 | CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK); |
515 | CHECK_LED (LED_SLEEP, LK_LED_WAIT); | 532 | CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT); |
516 | if (leds_on != 0) { | 533 | if (leds_on != 0) { |
517 | lk->serio->write (lk->serio, LK_CMD_LED_ON); | 534 | lk->serio->write (lk->serio, LK_CMD_LED_ON); |
518 | lk->serio->write (lk->serio, leds_on); | 535 | lk->serio->write (lk->serio, leds_on); |
@@ -574,10 +591,10 @@ lkkbd_reinit (void *data) | |||
574 | lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS); | 591 | lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS); |
575 | 592 | ||
576 | /* Set LEDs */ | 593 | /* Set LEDs */ |
577 | CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK); | 594 | CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK); |
578 | CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE); | 595 | CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE); |
579 | CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK); | 596 | CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK); |
580 | CHECK_LED (LED_SLEEP, LK_LED_WAIT); | 597 | CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT); |
581 | if (leds_on != 0) { | 598 | if (leds_on != 0) { |
582 | lk->serio->write (lk->serio, LK_CMD_LED_ON); | 599 | lk->serio->write (lk->serio, LK_CMD_LED_ON); |
583 | lk->serio->write (lk->serio, leds_on); | 600 | lk->serio->write (lk->serio, leds_on); |