mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org, Sebastian Reichel <sre@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] Input: tsc2004/5 - do not use irq_set_irq_wake() directly
Date: Thu, 11 Jul 2024 10:27:15 -0700	[thread overview]
Message-ID: <20240711172719.1248373-4-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20240711172719.1248373-1-dmitry.torokhov@gmail.com>

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.

This also allows changing the wakeup setting dynamically at runtime using
/sys/devices/.../tsc2005/power/wakeup.

Reviewed-By: Sebastian Reichel <sre@kernel.org>
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 87e6839c60fa..cd60bba11c56 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -106,7 +106,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,
@@ -560,7 +562,8 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
 		return error;
 	}
 
-	irq_set_irq_wake(irq, 1);
+	device_init_wakeup(dev, true);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(tsc200x_probe);
@@ -576,6 +579,9 @@ static int 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;
@@ -587,6 +593,11 @@ static int 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.45.2.993.g49e7a77208-goog


  parent reply	other threads:[~2024-07-11 17:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-11 17:27 [PATCH 1/6] Input: tsc2004/5 - fix handling of VIO power supply Dmitry Torokhov
2024-07-11 17:27 ` [PATCH 2/6] Input: tsc2004/5 - do not hard code interrupt trigger Dmitry Torokhov
2024-07-11 17:27 ` [PATCH 3/6] Input: tsc2004/5 - fix reset handling on probe Dmitry Torokhov
2024-07-11 17:27 ` Dmitry Torokhov [this message]
2024-07-11 17:27 ` [PATCH 5/6] Input: tsc2004/5 - respect "wakeup-source" property Dmitry Torokhov
2024-07-11 17:27 ` [PATCH 6/6] Input: tsc2004/5 - use guard notation when acquiring mutexes/locks Dmitry Torokhov
2024-08-05  1:11 ` [PATCH 1/6] Input: tsc2004/5 - fix handling of VIO power supply Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240711172719.1248373-4-dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®