From patchwork Wed Mar 28 06:16:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 10312177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40B2E60353 for ; Wed, 28 Mar 2018 06:16:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31D1129EC8 for ; Wed, 28 Mar 2018 06:16:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25CD529ECD; Wed, 28 Mar 2018 06:16:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8657B29EC8 for ; Wed, 28 Mar 2018 06:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752222AbeC1GQR (ORCPT ); Wed, 28 Mar 2018 02:16:17 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:40517 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbeC1GQQ (ORCPT ); Wed, 28 Mar 2018 02:16:16 -0400 Received: by mail-pf0-f193.google.com with SMTP id y66so574530pfi.7 for ; Tue, 27 Mar 2018 23:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=QWsKjjDOgmP2rY5rOyj/R4muXGpAMYKmOViEqSXiOP0=; b=R9vnJpx+UPJrOzJqM66YQekQrtF0dvNAoWAKbFsBlAzv8Q2ga0ms+6n0qORSDJAkfy A8kxoYiNS39DypViooqXVEegx68MIHORkwYIGWl2YYR6wRik4Lbj1KQnpCmmuqPkGgxH Te6mgx3C6m3y4gyBjHXxgFmJeJM+kniBWa1rw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QWsKjjDOgmP2rY5rOyj/R4muXGpAMYKmOViEqSXiOP0=; b=R46cknCtY5h4Mr9WF5kxJSicMaP7traaZ2ZLRTRlzHtuUWZPKHvjiRH7byOf+9eDzt dy4A9zvf/rOGCb8eZBZ6bfLnMdv54tg8DdFRMFo1YLX3Uvae3NjEYQjkIc2GZoJwE+lk g9FkKwZ1pj3DiqLCFnF80aAn7QvqW71vnEolZDwqDEUDaWHBHSM5mktHGN7ZPnR0eG+U Hzb3znYRicHIMo9pA76IBHFcUc1F7+cH4llCHTiq6/vegosknEEH4tHKW+74Mvpt0aai XTwAwep08pQ5DPGIxKI9aAqm2OyaZt5G2J0OIXhL+vVxB7gXlOBpeuOIlgxvQhZbGMmT fTkA== X-Gm-Message-State: AElRT7G3IbZTM9teGbBMTALDdcunZy5CmhVm/o6xNYXS0k7czU8Vbg1x WTRIBjjly2izVd3p9xd96QOD3A== X-Google-Smtp-Source: AIpwx4+nJgR4fijrVYaD9fw/m3VlU9hq1uEMvksdFmuje14/7ecZMAAcUabwyPeZ/7HqB2dlhzKVRA== X-Received: by 10.98.217.139 with SMTP id b11mr1898924pfl.113.1522217776036; Tue, 27 Mar 2018 23:16:16 -0700 (PDT) Received: from drinkcat.tpe.corp.google.com ([2401:fa00:1:b:9ba:cd16:d555:bacf]) by smtp.gmail.com with ESMTPSA id u10sm4921048pgr.83.2018.03.27.23.16.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 23:16:15 -0700 (PDT) From: Nicolas Boichat To: Jiri Kosina Cc: Benjamin Tissoires , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, groeck@chromium.org, dtor@chromium.org, Haridhar Kalvala Subject: [PATCH] HID: google: Enable PM Full On mode when adjusting backlight Date: Wed, 28 Mar 2018 14:16:10 +0800 Message-Id: <20180328061610.206090-1-drinkcat@chromium.org> X-Mailer: git-send-email 2.17.0.rc1.321.gba9d0f2565-goog Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Haridhar Kalvala 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 Reviewed-by: Dmitry Torokhov Signed-off-by: Nicolas Boichat --- drivers/hid/hid-google-hammer.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) Changes from version on Chromium OS gerrit (https://chromium-review.googlesource.com/735259): - Reworded and reflowed commit message, as well as comment in code. diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c index 6486469ce0f64..7b8e17b03cb86 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; }