* [PATCH v2] HID: i2c-hid: Only disable irq wake if it was successfully enabled during suspend
@ 2015-07-30 21:49 Andrew Duggan
2015-08-18 13:21 ` Jiri Kosina
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Duggan @ 2015-07-30 21:49 UTC (permalink / raw)
To: linux-input, linux-kernel
Cc: Andrew Duggan, Jiri Kosina, Benjamin Tissoires, Mika Westerberg
Enabling irq wake could potentially fail and calling disable_irq_wake
after a failed call to enable_irq_wake could result in an unbalanced irq
warning. This patch warns if enable_irq_wake fails and avoids other
potential issues caused by calling disable_irq_wake on resume after
enable_irq_wake failed during suspend.
Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
---
This patch is based on Jiri's for-4.3/i2c-hid and needs Gabriele Mazzotta's
patch which moves where the HID driver's suspend callback call to apply
cleanly.
drivers/hid/i2c-hid/i2c-hid.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 9ed69b5..2871f3c 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -149,6 +149,8 @@ struct i2c_hid {
int irq;
struct i2c_hid_platform_data pdata;
+
+ bool irq_wake_enabled;
};
static int __i2c_hid_command(struct i2c_client *client,
@@ -1091,13 +1093,20 @@ static int i2c_hid_suspend(struct device *dev)
struct i2c_hid *ihid = i2c_get_clientdata(client);
struct hid_device *hid = ihid->hid;
int ret = 0;
+ int wake_status;
if (hid->driver && hid->driver->suspend)
ret = hid->driver->suspend(hid, PMSG_SUSPEND);
disable_irq(ihid->irq);
- if (device_may_wakeup(&client->dev))
- enable_irq_wake(ihid->irq);
+ if (device_may_wakeup(&client->dev)) {
+ wake_status = enable_irq_wake(ihid->irq);
+ if (!wake_status)
+ ihid->irq_wake_enabled = true;
+ else
+ hid_warn(hid, "Failed to enable irq wake: %d\n",
+ wake_status);
+ }
/* Save some power */
i2c_hid_set_power(client, I2C_HID_PWR_SLEEP);
@@ -1111,14 +1120,21 @@ static int i2c_hid_resume(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct i2c_hid *ihid = i2c_get_clientdata(client);
struct hid_device *hid = ihid->hid;
+ int wake_status;
enable_irq(ihid->irq);
ret = i2c_hid_hwreset(client);
if (ret)
return ret;
- if (device_may_wakeup(&client->dev))
- disable_irq_wake(ihid->irq);
+ if (device_may_wakeup(&client->dev) && ihid->irq_wake_enabled) {
+ wake_status = disable_irq_wake(ihid->irq);
+ if (!wake_status)
+ ihid->irq_wake_enabled = false;
+ else
+ hid_warn(hid, "Failed to disable irq wake: %d\n",
+ wake_status);
+ }
if (hid->driver && hid->driver->reset_resume) {
ret = hid->driver->reset_resume(hid);
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] HID: i2c-hid: Only disable irq wake if it was successfully enabled during suspend
2015-07-30 21:49 [PATCH v2] HID: i2c-hid: Only disable irq wake if it was successfully enabled during suspend Andrew Duggan
@ 2015-08-18 13:21 ` Jiri Kosina
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2015-08-18 13:21 UTC (permalink / raw)
To: Andrew Duggan
Cc: linux-input, linux-kernel, Benjamin Tissoires, Mika Westerberg
On Thu, 30 Jul 2015, Andrew Duggan wrote:
> Enabling irq wake could potentially fail and calling disable_irq_wake
> after a failed call to enable_irq_wake could result in an unbalanced irq
> warning. This patch warns if enable_irq_wake fails and avoids other
> potential issues caused by calling disable_irq_wake on resume after
> enable_irq_wake failed during suspend.
>
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
> ---
> This patch is based on Jiri's for-4.3/i2c-hid and needs Gabriele Mazzotta's
> patch which moves where the HID driver's suspend callback call to apply
> cleanly.
Applied to for-4.3/i2c-hid. Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-18 13:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-30 21:49 [PATCH v2] HID: i2c-hid: Only disable irq wake if it was successfully enabled during suspend Andrew Duggan
2015-08-18 13:21 ` Jiri Kosina
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).