* [PATCH] Input: tsc2004/5 - do not use irq_set_irq_wake() directly
@ 2017-02-12 23:43 Dmitry Torokhov
2017-02-13 6:17 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Torokhov @ 2017-02-12 23:43 UTC (permalink / raw)
To: linux-input
Cc: Pavel Machek, Sebastian Reichel, Pali Rohár, Michael Welling,
linux-kernel
Instead of setting irq_set_irq_wake() directly in probe(), mark the device
as wakeup-capable, and use enable_irq_wake() and disable_irq_wake() in
suspend/resume path.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/tsc200x-core.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index 88ea5e1b72ae..d1c40c803d61 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -114,7 +114,9 @@ struct tsc200x {
struct gpio_desc *reset_gpio;
int (*tsc200x_cmd)(struct device *dev, u8 cmd);
+
int irq;
+ bool wake_irq_enabled;
};
static void tsc200x_update_pen_state(struct tsc200x *ts,
@@ -573,7 +575,8 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
goto err_remove_sysfs;
}
- irq_set_irq_wake(irq, 1);
+ device_init_wakeup(dev, true);
+
return 0;
err_remove_sysfs:
@@ -607,6 +610,9 @@ static int __maybe_unused tsc200x_suspend(struct device *dev)
ts->suspended = true;
+ if (device_may_wakeup(dev))
+ ts->wake_irq_enabled = enable_irq_wake(ts->irq) == 0;
+
mutex_unlock(&ts->mutex);
return 0;
@@ -618,6 +624,11 @@ static int __maybe_unused tsc200x_resume(struct device *dev)
mutex_lock(&ts->mutex);
+ if (ts->wake_irq_enabled) {
+ disable_irq_wake(ts->irq);
+ ts->wake_irq_enabled = false;
+ }
+
if (ts->suspended && ts->opened)
__tsc200x_enable(ts);
--
2.11.0.483.g087da7b7c-goog
--
Dmitry
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: tsc2004/5 - do not use irq_set_irq_wake() directly
2017-02-12 23:43 [PATCH] Input: tsc2004/5 - do not use irq_set_irq_wake() directly Dmitry Torokhov
@ 2017-02-13 6:17 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2017-02-13 6:17 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, Pavel Machek, Pali Rohár, Michael Welling,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2235 bytes --]
Hi,
On Sun, Feb 12, 2017 at 03:43:33PM -0800, Dmitry Torokhov wrote:
> Instead of setting irq_set_irq_wake() directly in probe(), mark the device
> as wakeup-capable, and use enable_irq_wake() and disable_irq_wake() in
> suspend/resume path.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-By: Sebastian Reichel <sre@kernel.org>
I suggest to add a paragraph in the patch description, why the
change was done. E.g.:
This adds support for changing the wakeup setting dynamically at
runtime using /sys/devices/.../tsc2005/power/wakeup.
Also I wonder if the default should be 'off' (by using
device_set_wakeup_capable() instead of device_init_wakeup()
-- Sebastian
> drivers/input/touchscreen/tsc200x-core.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
> index 88ea5e1b72ae..d1c40c803d61 100644
> --- a/drivers/input/touchscreen/tsc200x-core.c
> +++ b/drivers/input/touchscreen/tsc200x-core.c
> @@ -114,7 +114,9 @@ struct tsc200x {
>
> struct gpio_desc *reset_gpio;
> int (*tsc200x_cmd)(struct device *dev, u8 cmd);
> +
> int irq;
> + bool wake_irq_enabled;
> };
>
> static void tsc200x_update_pen_state(struct tsc200x *ts,
> @@ -573,7 +575,8 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
> goto err_remove_sysfs;
> }
>
> - irq_set_irq_wake(irq, 1);
> + device_init_wakeup(dev, true);
> +
> return 0;
>
> err_remove_sysfs:
> @@ -607,6 +610,9 @@ static int __maybe_unused tsc200x_suspend(struct device *dev)
>
> ts->suspended = true;
>
> + if (device_may_wakeup(dev))
> + ts->wake_irq_enabled = enable_irq_wake(ts->irq) == 0;
> +
> mutex_unlock(&ts->mutex);
>
> return 0;
> @@ -618,6 +624,11 @@ static int __maybe_unused tsc200x_resume(struct device *dev)
>
> mutex_lock(&ts->mutex);
>
> + if (ts->wake_irq_enabled) {
> + disable_irq_wake(ts->irq);
> + ts->wake_irq_enabled = false;
> + }
> +
> if (ts->suspended && ts->opened)
> __tsc200x_enable(ts);
>
> --
> 2.11.0.483.g087da7b7c-goog
>
>
> --
> Dmitry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-02-13 6:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-12 23:43 [PATCH] Input: tsc2004/5 - do not use irq_set_irq_wake() directly Dmitry Torokhov
2017-02-13 6:17 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).