summaryrefslogtreecommitdiff
path: root/drivers/input/mouse
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r--drivers/input/mouse/nvec_mouse.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/drivers/input/mouse/nvec_mouse.c b/drivers/input/mouse/nvec_mouse.c
index 7bf09627505d..2d66070aa498 100644
--- a/drivers/input/mouse/nvec_mouse.c
+++ b/drivers/input/mouse/nvec_mouse.c
@@ -304,6 +304,7 @@ static int __devinit nvec_mouse_probe(struct platform_device *pdev)
printk("**nvec_mouse_probe\n");
mouse = kzalloc(sizeof(struct nvec_mouse), GFP_KERNEL);
+ memset(mouse, 0, sizeof(struct nvec_mouse));
input_dev = input_allocate_device();
if (!mouse || !input_dev) {
printk("**nvec_mouse_probe: input_allocate_device: fail\n");
@@ -397,12 +398,15 @@ fail_input_register:
(void)kthread_stop(mouse->task);
fail_thread_create:
NvOdmOsSemaphoreDestroy(mouse->semaphore);
+ mouse->semaphore = NULL;
fail_semaphore_create:
fail_no_mouse_found:
NvOdmMouseDeviceClose(mouse->hDevice);
+ mouse->hDevice = NULL;
fail:
input_free_device(input_dev);
kfree(mouse);
+ mouse = NULL;
return error;
}
@@ -415,14 +419,61 @@ static int __devexit nvec_mouse_remove(struct platform_device *dev)
printk("**nvec_mouse_remove\n");
(void)kthread_stop(mouse->task);
NvOdmOsSemaphoreDestroy(mouse->semaphore);
+ mouse->semaphore = NULL;
NvOdmMouseDeviceClose(mouse->hDevice);
+ mouse->hDevice = NULL;
input_free_device(input_dev);
kfree(mouse);
+ mouse = NULL;
printk("**nvec_mouse_remove end\n");
return 0;
}
+static int nvec_mouse_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ struct input_dev *input_dev = platform_get_drvdata(pdev);
+ struct nvec_mouse *mouse = input_get_drvdata(input_dev);
+
+ if (!mouse)
+ return -1;
+
+ if (!mouse->hDevice) {
+ printk("%s: device handle NULL\n", __func__);
+ return -1;
+ }
+
+ /* power down hardware */
+ if (!NvOdmMousePowerSuspend(mouse->hDevice)) {
+ printk("%s: hardware power down fail\n", __func__);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int nvec_mouse_resume(struct platform_device *pdev)
+{
+ struct input_dev *input_dev = platform_get_drvdata(pdev);
+ struct nvec_mouse *mouse = input_get_drvdata(input_dev);
+
+ if (!mouse)
+ return -1;
+
+ if (!mouse->hDevice) {
+ printk("%s: device handle NULL\n", __func__);
+ return -1;
+ }
+
+ /* power up hardware */
+ if (!NvOdmMousePowerResume(mouse->hDevice)) {
+ printk("%s: hardware power up fail\n", __func__);
+ return -1;
+ }
+
+ return 0;
+}
+
static struct platform_driver nvec_mouse_driver = {
.driver = {
.name = "nvec_mouse",
@@ -430,9 +481,10 @@ static struct platform_driver nvec_mouse_driver = {
},
.probe = nvec_mouse_probe,
.remove = __devexit_p(nvec_mouse_remove),
+ .suspend = nvec_mouse_suspend,
+ .resume = nvec_mouse_resume,
};
-
static int __init nvec_mouse_init(void)
{
int err;