diff options
Diffstat (limited to 'drivers/staging/nvec/nvec_ps2.c')
-rw-r--r-- | drivers/staging/nvec/nvec_ps2.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c index d7c651102131..aff6b9b9f9aa 100644 --- a/drivers/staging/nvec/nvec_ps2.c +++ b/drivers/staging/nvec/nvec_ps2.c @@ -21,9 +21,11 @@ #include "nvec.h" -#define START_STREAMING {'\x06', '\x03', '\x06'} -#define STOP_STREAMING {'\x06', '\x04'} -#define SEND_COMMAND {'\x06', '\x01', '\xf4', '\x01'} +#define PACKET_SIZE 6 + +#define ENABLE_MOUSE 0xf4 +#define DISABLE_MOUSE 0xf5 +#define PSMOUSE_RST 0xff #ifdef NVEC_PS2_DEBUG #define NVEC_PHD(str, buf, len) \ @@ -33,7 +35,12 @@ #define NVEC_PHD(str, buf, len) #endif -static const unsigned char MOUSE_RESET[] = {'\x06', '\x01', '\xff', '\x03'}; +enum ps2_subcmds { + SEND_COMMAND = 1, + RECEIVE_N, + AUTO_RECEIVE_N, + CANCEL_AUTO_RECEIVE, +}; struct nvec_ps2 { struct serio *ser_dev; @@ -45,19 +52,19 @@ static struct nvec_ps2 ps2_dev; static int ps2_startstreaming(struct serio *ser_dev) { - unsigned char buf[] = START_STREAMING; + unsigned char buf[] = { NVEC_PS2, AUTO_RECEIVE_N, PACKET_SIZE }; return nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); } static void ps2_stopstreaming(struct serio *ser_dev) { - unsigned char buf[] = STOP_STREAMING; + unsigned char buf[] = { NVEC_PS2, CANCEL_AUTO_RECEIVE }; nvec_write_async(ps2_dev.nvec, buf, sizeof(buf)); } static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd) { - unsigned char buf[] = SEND_COMMAND; + unsigned char buf[] = { NVEC_PS2, SEND_COMMAND, ENABLE_MOUSE, 1 }; buf[2] = cmd & 0xff; @@ -93,10 +100,11 @@ static int nvec_ps2_notifier(struct notifier_block *nb, return NOTIFY_DONE; } -static int __devinit nvec_mouse_probe(struct platform_device *pdev) +static int nvec_mouse_probe(struct platform_device *pdev) { struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); struct serio *ser_dev; + char mouse_reset[] = { NVEC_PS2, SEND_COMMAND, PSMOUSE_RST, 3 }; ser_dev = devm_kzalloc(&pdev->dev, sizeof(struct serio), GFP_KERNEL); if (ser_dev == NULL) @@ -118,12 +126,12 @@ static int __devinit nvec_mouse_probe(struct platform_device *pdev) serio_register_port(ser_dev); /* mouse reset */ - nvec_write_async(nvec, MOUSE_RESET, 4); + nvec_write_async(nvec, mouse_reset, sizeof(mouse_reset)); return 0; } -static int __devexit nvec_mouse_remove(struct platform_device *pdev) +static int nvec_mouse_remove(struct platform_device *pdev) { serio_unregister_port(ps2_dev.ser_dev); @@ -133,27 +141,22 @@ static int __devexit nvec_mouse_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int nvec_mouse_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); - /* disable mouse */ - nvec_write_async(nvec, "\x06\xf4", 2); + ps2_sendcommand(ps2_dev.ser_dev, DISABLE_MOUSE); /* send cancel autoreceive */ - nvec_write_async(nvec, "\x06\x04", 2); + ps2_stopstreaming(ps2_dev.ser_dev); return 0; } static int nvec_mouse_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); - + /* start streaming */ ps2_startstreaming(ps2_dev.ser_dev); /* enable mouse */ - nvec_write_async(nvec, "\x06\xf5", 2); + ps2_sendcommand(ps2_dev.ser_dev, ENABLE_MOUSE); return 0; } @@ -164,7 +167,7 @@ static const SIMPLE_DEV_PM_OPS(nvec_mouse_pm_ops, nvec_mouse_suspend, static struct platform_driver nvec_mouse_driver = { .probe = nvec_mouse_probe, - .remove = __devexit_p(nvec_mouse_remove), + .remove = nvec_mouse_remove, .driver = { .name = "nvec-mouse", .owner = THIS_MODULE, |