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>
diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c
index 7cb149b..7445ce6 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 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_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 @@
 	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 @@
 	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;