linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/4] Input: gpio_keys - store a pointer to driver_data in button_data
@ 2017-10-30 17:40 Hans de Goede
  2017-10-30 17:40 ` [PATCH v3 2/4] Input: gpio_keys - Use a single suspended flag per device Hans de Goede
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Hans de Goede @ 2017-10-30 17:40 UTC (permalink / raw)
  To: Dmitry Torokhov, Benjamin Tissoires; +Cc: Hans de Goede, linux-input

Instead of a pointer to the input_dev, store a pointer the
gpio_keys_drvdata struct in struct gpio_button_data, so that per button
ISRs can access the entire driver-data struct and we don't need to
store a copy of global state (e.g. the suspended flag) for each button.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v3:
-This is a new patch in v3 of this patch-set
---
 drivers/input/keyboard/gpio_keys.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 87e613dc33b8..36ab7daba957 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -31,9 +31,11 @@
 #include <linux/of_irq.h>
 #include <linux/spinlock.h>
 
+struct gpio_keys_drvdata;
+
 struct gpio_button_data {
 	const struct gpio_keys_button *button;
-	struct input_dev *input;
+	struct gpio_keys_drvdata *ddata;
 	struct gpio_desc *gpiod;
 
 	unsigned short *code;
@@ -360,7 +362,7 @@ static const struct attribute_group gpio_keys_attr_group = {
 static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
 {
 	const struct gpio_keys_button *button = bdata->button;
-	struct input_dev *input = bdata->input;
+	struct input_dev *input = bdata->ddata->input;
 	unsigned int type = button->type ?: EV_KEY;
 	int state;
 
@@ -388,19 +390,20 @@ static void gpio_keys_gpio_work_func(struct work_struct *work)
 	gpio_keys_gpio_report_event(bdata);
 
 	if (bdata->button->wakeup)
-		pm_relax(bdata->input->dev.parent);
+		pm_relax(bdata->ddata->input->dev.parent);
 }
 
 static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
 {
 	struct gpio_button_data *bdata = dev_id;
+	struct input_dev *input = bdata->ddata->input;
 
 	BUG_ON(irq != bdata->irq);
 
 	if (bdata->button->wakeup) {
 		const struct gpio_keys_button *button = bdata->button;
 
-		pm_stay_awake(bdata->input->dev.parent);
+		pm_stay_awake(input->dev.parent);
 		if (bdata->suspended  &&
 		    (button->type == 0 || button->type == EV_KEY)) {
 			/*
@@ -408,7 +411,7 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
 			 * already released by the time we got interrupt
 			 * handler to run.
 			 */
-			input_report_key(bdata->input, button->code, 1);
+			input_report_key(input, button->code, 1);
 		}
 	}
 
@@ -422,7 +425,7 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
 static void gpio_keys_irq_timer(struct timer_list *t)
 {
 	struct gpio_button_data *bdata = from_timer(bdata, t, release_timer);
-	struct input_dev *input = bdata->input;
+	struct input_dev *input = bdata->ddata->input;
 	unsigned long flags;
 
 	spin_lock_irqsave(&bdata->lock, flags);
@@ -437,7 +440,7 @@ static void gpio_keys_irq_timer(struct timer_list *t)
 static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
 {
 	struct gpio_button_data *bdata = dev_id;
-	struct input_dev *input = bdata->input;
+	struct input_dev *input = bdata->ddata->input;
 	unsigned long flags;
 
 	BUG_ON(irq != bdata->irq);
@@ -446,7 +449,7 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
 
 	if (!bdata->key_pressed) {
 		if (bdata->button->wakeup)
-			pm_wakeup_event(bdata->input->dev.parent, 0);
+			pm_wakeup_event(input->dev.parent, 0);
 
 		input_event(input, EV_KEY, *bdata->code, 1);
 		input_sync(input);
@@ -493,7 +496,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 	int irq;
 	int error;
 
-	bdata->input = input;
+	bdata->ddata = ddata;
 	bdata->button = button;
 	spin_lock_init(&bdata->lock);
 
-- 
2.14.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-11-06 13:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-30 17:40 [PATCH v3 1/4] Input: gpio_keys - store a pointer to driver_data in button_data Hans de Goede
2017-10-30 17:40 ` [PATCH v3 2/4] Input: gpio_keys - Use a single suspended flag per device Hans de Goede
2017-10-30 17:40 ` [PATCH v3 3/4] Input: gpio_keys - Allow suppression of input events for wakeup button presses Hans de Goede
2017-10-30 18:17   ` Dmitry Torokhov
2017-10-30 20:08     ` Hans de Goede
2017-10-30 20:48       ` Dmitry Torokhov
2017-11-01 15:27         ` Hans de Goede
2017-11-06  9:19           ` Benjamin Tissoires
2017-11-06 13:54             ` Hans de Goede
2017-10-30 17:40 ` [PATCH v3 4/4] Input: soc_button_array - Suppress power button presses during suspend Hans de Goede

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).