summaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-google-hammer.c
diff options
context:
space:
mode:
authorHaridhar Kalvala <haridhar.kalvala@intel.com>2018-03-28 08:16:10 +0200
committerJiri Kosina <jkosina@suse.cz>2018-03-28 16:12:58 +0200
commit7d3d88401fb75081e731d62c1c79584413525aa6 (patch)
treefd18e36c6f2148f9aa21bf9ac08c316e4e82657f /drivers/hid/hid-google-hammer.c
parentHID: google: add google hammer HID driver (diff)
downloadlinux-7d3d88401fb75081e731d62c1c79584413525aa6.tar.xz
linux-7d3d88401fb75081e731d62c1c79584413525aa6.zip
HID: google: Enable PM Full On mode when adjusting backlight
hammer LED backlight brightness is not getting set when USB device is in suspend state. This patch fixes the issue by requesting USB HID device to be in FULLON mode, so that sending hardware output report and hardware raw request won't fail to set brightness, and set device back to NORMAL mode once this call returns. Signed-off-by: Haridhar Kalvala <haridhar.kalvala@intel.com> Reviewed-by: Dmitry Torokhov <dtor@chromium.org> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-google-hammer.c')
-rw-r--r--drivers/hid/hid-google-hammer.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c
index 6486469ce0f6..7b8e17b03cb8 100644
--- a/drivers/hid/hid-google-hammer.c
+++ b/drivers/hid/hid-google-hammer.c
@@ -41,6 +41,16 @@ static int hammer_kbd_brightness_set_blocking(struct led_classdev *cdev,
led->buf[0] = 0;
led->buf[1] = br;
+ /*
+ * Request USB HID device to be in Full On mode, so that sending
+ * hardware output report and hardware raw request won't fail.
+ */
+ ret = hid_hw_power(led->hdev, PM_HINT_FULLON);
+ if (ret < 0) {
+ hid_err(led->hdev, "failed: device not resumed %d\n", ret);
+ return ret;
+ }
+
ret = hid_hw_output_report(led->hdev, led->buf, sizeof(led->buf));
if (ret == -ENOSYS)
ret = hid_hw_raw_request(led->hdev, 0, led->buf,
@@ -50,6 +60,10 @@ static int hammer_kbd_brightness_set_blocking(struct led_classdev *cdev,
if (ret < 0)
hid_err(led->hdev, "failed to set keyboard backlight: %d\n",
ret);
+
+ /* Request USB HID device back to Normal Mode. */
+ hid_hw_power(led->hdev, PM_HINT_NORMAL);
+
return ret;
}