All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>, linux-input@vger.kernel.org
Subject: [PATCH v3 2/4] Input: gpio_keys - Use a single suspended flag per device
Date: Mon, 30 Oct 2017 18:40:48 +0100	[thread overview]
Message-ID: <20171030174050.30375-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20171030174050.30375-1-hdegoede@redhat.com>

There is no need to have a suspended flag per button, this also
allows gpio_keys_resume to set suspended to false after calling
gpio_keys_report_state, which will allow testing the suspended flag
in gpio_keys_report_state in a follow-up patch.

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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 36ab7daba957..9b51aa56cc83 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -50,7 +50,6 @@ struct gpio_button_data {
 	spinlock_t lock;
 	bool disabled;
 	bool key_pressed;
-	bool suspended;
 };
 
 struct gpio_keys_drvdata {
@@ -58,6 +57,7 @@ struct gpio_keys_drvdata {
 	struct input_dev *input;
 	struct mutex disable_lock;
 	unsigned short *keymap;
+	bool suspended;
 	struct gpio_button_data data[0];
 };
 
@@ -404,7 +404,7 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
 		const struct gpio_keys_button *button = bdata->button;
 
 		pm_stay_awake(input->dev.parent);
-		if (bdata->suspended  &&
+		if (bdata->ddata->suspended  &&
 		    (button->type == 0 || button->type == EV_KEY)) {
 			/*
 			 * Simulate wakeup key press in case the key has
@@ -859,7 +859,6 @@ static int __maybe_unused gpio_keys_suspend(struct device *dev)
 			struct gpio_button_data *bdata = &ddata->data[i];
 			if (bdata->button->wakeup)
 				enable_irq_wake(bdata->irq);
-			bdata->suspended = true;
 		}
 	} else {
 		mutex_lock(&input->mutex);
@@ -868,6 +867,7 @@ static int __maybe_unused gpio_keys_suspend(struct device *dev)
 		mutex_unlock(&input->mutex);
 	}
 
+	ddata->suspended = true;
 	return 0;
 }
 
@@ -883,7 +883,6 @@ static int __maybe_unused gpio_keys_resume(struct device *dev)
 			struct gpio_button_data *bdata = &ddata->data[i];
 			if (bdata->button->wakeup)
 				disable_irq_wake(bdata->irq);
-			bdata->suspended = false;
 		}
 	} else {
 		mutex_lock(&input->mutex);
@@ -896,6 +895,7 @@ static int __maybe_unused gpio_keys_resume(struct device *dev)
 		return error;
 
 	gpio_keys_report_state(ddata);
+	ddata->suspended = false;
 	return 0;
 }
 
-- 
2.14.2


  reply	other threads:[~2017-10-30 17:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Hans de Goede [this message]
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

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=20171030174050.30375-2-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.