]> git.karo-electronics.de Git - karo-tx-linux.git/commit
HID: i2c-hid: Fix suspend/resume when already runtime suspended
authorDoug Anderson <dianders@chromium.org>
Tue, 8 Mar 2016 23:03:23 +0000 (15:03 -0800)
committerJiri Kosina <jkosina@suse.cz>
Thu, 10 Mar 2016 09:04:22 +0000 (10:04 +0100)
commit01714a6f5fa59a313d8f44dcf017911dfcb25831
treefef2ac3e89d7ed5bb2392d5ad25751ddca7af072
parent1dcdde98bcbd5a9f0ce94bc2080ec31e71a8d811
HID: i2c-hid: Fix suspend/resume when already runtime suspended

On ACPI-based systems ACPI power domain code runtime resumes device before
calling suspend method, which ensures that i2c-hid suspend code starts with
device not in low-power state and with interrupts enabled.

On other systems, especially if device is not a part of any power domain,
we may end up calling driver's system-level suspend routine while the
device is runtime-suspended (with controller in presumably low power state
and interrupts disabled). This will result in interrupts being essentially
disabled twice, and we will only re-enable them after both system resume
and runtime resume methods complete. Unfortunately i2c_hid_resume() calls
i2c_hid_hwreset() and that only works properly if interrupts are enabled.

Also if device is runtime-suspended driver's suspend code may fail if it
tries to issue I/O requests.

Let's fix it by runtime-resuming the device if we need to run HID driver's
suspend code and also disabling interrupts only if device is not already
runtime-suspended. Also on resume we mark the device as running at full
power (since that is what resetting will do to it).

Reviewed-by: Benson Leung <bleung@chromium.org>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/i2c-hid/i2c-hid.c