diff options
author | Jonas Aaberg <jonas.aberg@stericsson.com> | 2012-11-24 03:10:29 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-11-28 01:40:07 -0500 |
commit | dda19a92f033399641e47db0b75beb01d001146b (patch) | |
tree | c2608f4ddc81920f8ba24a6fda12790b63796f9c | |
parent | 5b76d7b4cd965a84d922f303fe51a49cca89f9bb (diff) |
Input: gpio_keys - disable hardware on suspend
Disable hardware if active when suspending if the hw can not
wake the system from suspend.
[Dmitry Torokhov: use input_dev->users instead of a separate flag]
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Signed-off-by: Philippe Langlais <philippe.langlais@linaro.org>
Reviewed-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index c7764ca17b88..79435de0caa8 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -803,6 +803,7 @@ static int gpio_keys_remove(struct platform_device *pdev) | |||
803 | static int gpio_keys_suspend(struct device *dev) | 803 | static int gpio_keys_suspend(struct device *dev) |
804 | { | 804 | { |
805 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); | 805 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); |
806 | struct input_dev *input = ddata->input; | ||
806 | int i; | 807 | int i; |
807 | 808 | ||
808 | if (device_may_wakeup(dev)) { | 809 | if (device_may_wakeup(dev)) { |
@@ -811,6 +812,11 @@ static int gpio_keys_suspend(struct device *dev) | |||
811 | if (bdata->button->wakeup) | 812 | if (bdata->button->wakeup) |
812 | enable_irq_wake(bdata->irq); | 813 | enable_irq_wake(bdata->irq); |
813 | } | 814 | } |
815 | } else { | ||
816 | mutex_lock(&input->mutex); | ||
817 | if (input->users) | ||
818 | gpio_keys_close(input); | ||
819 | mutex_unlock(&input->mutex); | ||
814 | } | 820 | } |
815 | 821 | ||
816 | return 0; | 822 | return 0; |
@@ -819,16 +825,27 @@ static int gpio_keys_suspend(struct device *dev) | |||
819 | static int gpio_keys_resume(struct device *dev) | 825 | static int gpio_keys_resume(struct device *dev) |
820 | { | 826 | { |
821 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); | 827 | struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); |
828 | struct input_dev *input = ddata->input; | ||
829 | int error = 0; | ||
822 | int i; | 830 | int i; |
823 | 831 | ||
824 | for (i = 0; i < ddata->pdata->nbuttons; i++) { | 832 | if (device_may_wakeup(dev)) { |
825 | struct gpio_button_data *bdata = &ddata->data[i]; | 833 | for (i = 0; i < ddata->pdata->nbuttons; i++) { |
826 | if (bdata->button->wakeup && device_may_wakeup(dev)) | 834 | struct gpio_button_data *bdata = &ddata->data[i]; |
827 | disable_irq_wake(bdata->irq); | 835 | if (bdata->button->wakeup) |
836 | disable_irq_wake(bdata->irq); | ||
837 | } | ||
838 | } else { | ||
839 | mutex_lock(&input->mutex); | ||
840 | if (input->users) | ||
841 | error = gpio_keys_open(input); | ||
842 | mutex_unlock(&input->mutex); | ||
828 | } | 843 | } |
829 | 844 | ||
830 | gpio_keys_report_state(ddata); | 845 | if (error) |
846 | return error; | ||
831 | 847 | ||
848 | gpio_keys_report_state(ddata); | ||
832 | return 0; | 849 | return 0; |
833 | } | 850 | } |
834 | #endif | 851 | #endif |