diff options
author | Arve Hjønnevåg <arve@android.com> | 2012-04-16 12:42:49 +0530 |
---|---|---|
committer | Varun Wadekar <vwadekar@nvidia.com> | 2012-04-16 15:15:51 +0530 |
commit | b1416f82ba86781e4c6ea9a8bf7e3eadafa6ac12 (patch) | |
tree | e437bd5e1a7efb43e01e02b75142500a3a9bfabc /drivers | |
parent | 47f95e9e9830ffc5d8e9aac12f1ac3ce82d3be03 (diff) |
Input: Generic GPIO Input device.
Supports keyboard matrixces, direct inputs, direct outputs and axes connected to gpios.
Change-Id: I5e921e6e3a1cc169316ee3b665f4cc21b5735114
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Nick Pelly <npelly@google.com>
Conflicts:
drivers/input/misc/gpio_event.c
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/misc/gpio_event.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/drivers/input/misc/gpio_event.c b/drivers/input/misc/gpio_event.c index c7f396ab3eab..a98be67d1ab0 100644 --- a/drivers/input/misc/gpio_event.c +++ b/drivers/input/misc/gpio_event.c @@ -13,6 +13,7 @@ * */ +#include <linux/earlysuspend.h> #include <linux/module.h> #include <linux/input.h> #include <linux/gpio_event.h> @@ -23,6 +24,7 @@ struct gpio_event { struct gpio_event_input_devs *input_devs; const struct gpio_event_platform_data *info; + struct early_suspend early_suspend; void *state[0]; }; @@ -99,19 +101,23 @@ err_no_func: return ret; } -static void __maybe_unused gpio_event_suspend(struct gpio_event *ip) +#ifdef CONFIG_HAS_EARLYSUSPEND +void gpio_event_suspend(struct early_suspend *h) { + struct gpio_event *ip; + ip = container_of(h, struct gpio_event, early_suspend); gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_SUSPEND); - if (ip->info->power) - ip->info->power(ip->info, 0); + ip->info->power(ip->info, 0); } -static void __maybe_unused gpio_event_resume(struct gpio_event *ip) +void gpio_event_resume(struct early_suspend *h) { - if (ip->info->power) - ip->info->power(ip->info, 1); + struct gpio_event *ip; + ip = container_of(h, struct gpio_event, early_suspend); + ip->info->power(ip->info, 1); gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_RESUME); } +#endif static int gpio_event_probe(struct platform_device *pdev) { @@ -163,8 +169,15 @@ static int gpio_event_probe(struct platform_device *pdev) } ip->input_devs->count = dev_count; ip->info = event_info; - if (event_info->power) + if (event_info->power) { +#ifdef CONFIG_HAS_EARLYSUSPEND + ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; + ip->early_suspend.suspend = gpio_event_suspend; + ip->early_suspend.resume = gpio_event_resume; + register_early_suspend(&ip->early_suspend); +#endif ip->info->power(ip->info, 1); + } err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) @@ -185,8 +198,12 @@ static int gpio_event_probe(struct platform_device *pdev) err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: - if (event_info->power) + if (event_info->power) { +#ifdef CONFIG_HAS_EARLYSUSPEND + unregister_early_suspend(&ip->early_suspend); +#endif ip->info->power(ip->info, 0); + } for (i = 0; i < registered; i++) input_unregister_device(ip->input_devs->dev[i]); for (i = dev_count - 1; i >= registered; i--) { @@ -205,8 +222,12 @@ static int gpio_event_remove(struct platform_device *pdev) int i; gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); - if (ip->info->power) + if (ip->info->power) { +#ifdef CONFIG_HAS_EARLYSUSPEND + unregister_early_suspend(&ip->early_suspend); +#endif ip->info->power(ip->info, 0); + } for (i = 0; i < ip->input_devs->count; i++) input_unregister_device(ip->input_devs->dev[i]); kfree(ip); |