From ef76f388b9cace00bfe2e17ef97b7df5c442ad4a Mon Sep 17 00:00:00 2001 From: Jonas Aaberg Date: Fri, 30 Sep 2011 13:10:26 +0200 Subject: input: gpio-keys: Disable hw on suspend Disable hw if active when suspending if the hw can't wake the system from suspend. ST-Ericsson Linux next: - ST-Ericsson ID: - ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Ieaf2a2022b23782bc19afa152dc5e3fa5a0024ad Signed-off-by: Jonas Aaberg Signed-off-by: Philippe Langlais Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/32721 Reviewed-by: Bengt JONSSON --- drivers/input/keyboard/gpio_keys.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/input/keyboard/gpio_keys.c') diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index ed1ed469d08..523ef6cd03c 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -42,6 +42,8 @@ struct gpio_keys_drvdata { struct input_dev *input; struct mutex disable_lock; unsigned int n_buttons; + bool enabled; + bool enable_after_suspend; int (*enable)(struct device *dev); void (*disable)(struct device *dev); struct gpio_button_data data[0]; @@ -437,6 +439,7 @@ static int gpio_keys_open(struct input_dev *input) { struct gpio_keys_drvdata *ddata = input_get_drvdata(input); + ddata->enabled = true; return ddata->enable ? ddata->enable(input->dev.parent) : 0; } @@ -446,6 +449,7 @@ static void gpio_keys_close(struct input_dev *input) if (ddata->disable) ddata->disable(input->dev.parent); + ddata->enabled = false; } /* @@ -578,6 +582,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; + ddata->enabled = false; mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); @@ -709,6 +714,10 @@ static int gpio_keys_suspend(struct device *dev) enable_irq_wake(irq); } } + } else { + ddata->enable_after_suspend = ddata->enabled; + if (ddata->enabled) + gpio_keys_close(ddata->input); } return 0; @@ -729,6 +738,10 @@ static int gpio_keys_resume(struct device *dev) gpio_keys_report_event(&ddata->data[i]); } + + if (!device_may_wakeup(dev) && ddata->enable_after_suspend) + gpio_keys_open(ddata->input); + input_sync(ddata->input); return 0; -- cgit v1.2.3 From 60a369de2c9adf0bda48479f6f7ff24811609f3f Mon Sep 17 00:00:00 2001 From: Jonas Aaberg Date: Tue, 15 Nov 2011 10:41:34 +0100 Subject: drivers: gpio-keys: Add runtime support ST-Ericsson Linux next: - ST-Ericsson ID: 370799 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I14fc29c024e8d9b970cb9c0753cef72e2e61a0ca Signed-off-by: Jonas Aaberg Signed-off-by: Philippe Langlais Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/37778 Reviewed-by: QABUILD Reviewed-by: Bengt JONSSON --- drivers/input/keyboard/gpio_keys.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'drivers/input/keyboard/gpio_keys.c') diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 523ef6cd03c..a6d4ae1a23a 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -28,6 +28,7 @@ #include #include #include +#include struct gpio_button_data { struct gpio_keys_button *button; @@ -439,6 +440,7 @@ static int gpio_keys_open(struct input_dev *input) { struct gpio_keys_drvdata *ddata = input_get_drvdata(input); + pm_runtime_get_sync(input->dev.parent); ddata->enabled = true; return ddata->enable ? ddata->enable(input->dev.parent) : 0; } @@ -450,6 +452,7 @@ static void gpio_keys_close(struct input_dev *input) if (ddata->disable) ddata->disable(input->dev.parent); ddata->enabled = false; + pm_runtime_put(input->dev.parent); } /* @@ -599,6 +602,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) input->id.product = 0x0001; input->id.version = 0x0100; + pm_runtime_enable(&pdev->dev); + /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); @@ -672,6 +677,8 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev) struct input_dev *input = ddata->input; int i; + pm_runtime_disable(&pdev->dev); + sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); device_init_wakeup(&pdev->dev, 0); @@ -716,8 +723,8 @@ static int gpio_keys_suspend(struct device *dev) } } else { ddata->enable_after_suspend = ddata->enabled; - if (ddata->enabled) - gpio_keys_close(ddata->input); + if (ddata->enabled && ddata->disable) + ddata->disable(dev); } return 0; @@ -739,8 +746,9 @@ static int gpio_keys_resume(struct device *dev) gpio_keys_report_event(&ddata->data[i]); } - if (!device_may_wakeup(dev) && ddata->enable_after_suspend) - gpio_keys_open(ddata->input); + if (!device_may_wakeup(dev) && ddata->enable_after_suspend + && ddata->enable) + ddata->enable(dev); input_sync(ddata->input); -- cgit v1.2.3