diff options
author | Marc Dietrich <marvin24@gmx.de> | 2013-01-27 20:43:43 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-30 08:25:10 +0400 |
commit | 93eff83ff1640bef8062568687b5e0e41a0d4c42 (patch) | |
tree | 384fd726fb069c875f6070da4df4c57a55d33c48 /drivers/staging/nvec/nvec_kbd.c | |
parent | 85a90528b2b4f2d38a56df5b3f137223983aad4b (diff) | |
download | linux-93eff83ff1640bef8062568687b5e0e41a0d4c42.tar.xz |
staging: nvec: cleanup the string mess
Replace the various command strings by named constants.
Signed-off-by: Marc Dietrich <marvin24@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/nvec/nvec_kbd.c')
-rw-r--r-- | drivers/staging/nvec/nvec_kbd.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index 7cb149bf3d3f..7445ce6422bb 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -21,10 +21,14 @@ #include "nvec-keytable.h" #include "nvec.h" -#define ACK_KBD_EVENT {'\x05', '\xed', '\x01'} +enum kbd_subcmds { + CNFG_WAKE = 3, + CNFG_WAKE_KEY_REPORTING, + SET_LEDS = 0xed, + ENABLE_KBD = 0xf4, + DISABLE_KBD, +}; -static const char led_on[3] = "\x05\xed\x07"; -static const char led_off[3] = "\x05\xed\x00"; static unsigned char keycodes[ARRAY_SIZE(code_tab_102us) + ARRAY_SIZE(extcode_tab_us102)]; @@ -39,12 +43,15 @@ static struct nvec_keys keys_dev; static void nvec_kbd_toggle_led(void) { + char buf[] = { NVEC_KBD, SET_LEDS, 0 }; + keys_dev.caps_lock = !keys_dev.caps_lock; if (keys_dev.caps_lock) - nvec_write_async(keys_dev.nvec, led_on, sizeof(led_on)); - else - nvec_write_async(keys_dev.nvec, led_off, sizeof(led_off)); + /* should be BIT(0) only, firmware bug? */ + buf[2] = BIT(0) | BIT(1) | BIT(2); + + nvec_write_async(keys_dev.nvec, buf, sizeof(buf)); } static int nvec_keys_notifier(struct notifier_block *nb, @@ -82,8 +89,8 @@ static int nvec_keys_notifier(struct notifier_block *nb, static int nvec_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { - unsigned char buf[] = ACK_KBD_EVENT; struct nvec_chip *nvec = keys_dev.nvec; + char buf[] = { NVEC_KBD, SET_LEDS, 0 }; if (type == EV_REP) return 0; @@ -105,6 +112,11 @@ static int nvec_kbd_probe(struct platform_device *pdev) struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); int i, j, err; struct input_dev *idev; + char clear_leds[] = { NVEC_KBD, SET_LEDS, 0 }, + enable_kbd[] = { NVEC_KBD, ENABLE_KBD }, + cnfg_wake[] = { NVEC_KBD, CNFG_WAKE, true, true }, + cnfg_wake_key_reporting[] = { NVEC_KBD, CNFG_WAKE_KEY_REPORTING, + true }; j = 0; @@ -138,19 +150,15 @@ static int nvec_kbd_probe(struct platform_device *pdev) nvec_register_notifier(nvec, &keys_dev.notifier, 0); /* Enable keyboard */ - nvec_write_async(nvec, "\x05\xf4", 2); + nvec_write_async(nvec, enable_kbd, 2); - /* keyboard reset? */ - nvec_write_async(nvec, "\x05\x03\x01\x01", 4); - nvec_write_async(nvec, "\x05\x04\x01", 3); - nvec_write_async(nvec, "\x06\x01\xff\x03", 4); -/* FIXME - wait until keyboard reset is finished - or until we have a sync write */ - mdelay(1000); + /* configures wake on special keys */ + nvec_write_async(nvec, cnfg_wake, 4); + /* enable wake key reporting */ + nvec_write_async(nvec, cnfg_wake_key_reporting, 3); /* Disable caps lock LED */ - nvec_write_async(nvec, led_off, sizeof(led_off)); + nvec_write_async(nvec, clear_leds, sizeof(clear_leds)); return 0; |