Skip to contentSkip to conversation

Input: tsc2004/5 - do not use irq_set_irq_wake() directly

PATCH In review Dmitry Torokhov 2 participants 2 messages Feb 12, 2017 – Feb 13, 2017

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: tsc2004/5 - do not use irq_set_irq_wake() directly

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.

---
 drivers/input/touchscreen/tsc200x-core.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/input/touchscreen/tsc200x-core.c +12 -1
index 88ea5e1b72ae..d1c40c803d61 100644
@@ -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);
 
Signature · 5 lines
2.11.0.483.g087da7b7c-goog


-- 
Dmitry
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 5 lines · Dmitry Torokhov

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.

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

Quoted 55 lines
 drivers/input/touchscreen/tsc200x-core.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/input/touchscreen/tsc200x-core.c +12 -1
index 88ea5e1b72ae..d1c40c803d61 100644
@@ -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);
 
Signature · 5 lines
2.11.0.483.g087da7b7c-goog


-- 
Dmitry