From patchwork Wed Mar 23 14:08:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Rydberg X-Patchwork-Id: 88176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 169B0B6EFE for ; Thu, 24 Mar 2011 23:28:56 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Q2jeg-0004ge-D8; Thu, 24 Mar 2011 12:28:46 +0000 Received: from ch-smtp05.sth.basefarm.net ([80.76.153.6]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Q2OgE-0002ee-Kt for kernel-team@lists.ubuntu.com; Wed, 23 Mar 2011 14:04:58 +0000 Received: from c83-254-52-20.bredband.comhem.se ([83.254.52.20]:53452 helo=polaris) by ch-smtp05.sth.basefarm.net with smtp (Exim 4.73) (envelope-from ) id 1Q2OfZ-0001st-HE; Wed, 23 Mar 2011 15:04:20 +0100 Received: by polaris (sSMTP sendmail emulation); Wed, 23 Mar 2011 15:08:14 +0100 From: "Henrik Rydberg" To: Leann Ogasawara Subject: [PATCH] HID: ntrig: fix suspend/resume on recent models Date: Wed, 23 Mar 2011 15:08:14 +0100 Message-Id: <1300889294-17504-1-git-send-email-rydberg@euromail.se> X-Mailer: git-send-email 1.7.4.1 X-Originating-IP: 83.254.52.20 X-Scan-Result: No virus found in message 1Q2OfZ-0001st-HE. X-Scan-Signature: ch-smtp05.sth.basefarm.net 1Q2OfZ-0001st-HE 6c4d95688876683b5ea68608dd040a48 X-Mailman-Approved-At: Thu, 24 Mar 2011 12:28:45 +0000 Cc: kernel-team@lists.ubuntu.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com The recent 1b96:0006 model does not come up after suspend, which seems to be related to the initialization problems reported upstream. This patch adds a wakeup call via the reset-resume hook, which fixes the problem. Tested on older hardware without sign of regressions. Signed-off-by: Henrik Rydberg --- drivers/hid/hid-ntrig.c | 49 +++++++++++++++++++++++++++++++--------------- 1 files changed, 33 insertions(+), 16 deletions(-) diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c index 3e8d058..f8ea540 100644 --- a/drivers/hid/hid-ntrig.c +++ b/drivers/hid/hid-ntrig.c @@ -105,6 +105,27 @@ static inline void ntrig_set_mode(struct hid_device *hdev, const int mode) usbhid_submit_report(hdev, report, USB_DIR_IN); } +static void ntrig_set_report(struct hid_device *hdev) +{ + struct hid_report *report; + + /* This is needed for devices with more recent firmware versions */ + report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a]; + if (report) { + /* Let the device settle to ensure the wakeup message gets + * through */ + usbhid_wait_io(hdev); + usbhid_submit_report(hdev, report, USB_DIR_IN); + + /* + * Sanity check: if the current mode is invalid reset it to + * something reasonable. + */ + if (ntrig_get_mode(hdev) >= 4) + ntrig_set_mode(hdev, 3); + } +} + static void ntrig_report_version(struct hid_device *hdev) { int ret; @@ -433,7 +454,6 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) struct ntrig_data *nd; struct hid_input *hidinput; struct input_dev *input; - struct hid_report *report; if (id->driver_data & NTRIG_DUPLICATE_USAGES) hdev->quirks |= HID_QUIRK_MULTI_INPUT; @@ -480,21 +500,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) } } - /* This is needed for devices with more recent firmware versions */ - report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a]; - if (report) { - /* Let the device settle to ensure the wakeup message gets - * through */ - usbhid_wait_io(hdev); - usbhid_submit_report(hdev, report, USB_DIR_IN); - - /* - * Sanity check: if the current mode is invalid reset it to - * something reasonable. - */ - if (ntrig_get_mode(hdev) >= 4) - ntrig_set_mode(hdev, 3); - } + ntrig_set_report(hdev); ntrig_report_version(hdev); @@ -504,6 +510,14 @@ err_free: return ret; } +#ifdef CONFIG_PM +static int ntrig_reset_resume(struct hid_device *hdev) +{ + ntrig_set_report(hdev); + return 0; +} +#endif + static void ntrig_remove(struct hid_device *hdev) { hid_hw_stop(hdev); @@ -534,6 +548,9 @@ static struct hid_driver ntrig_driver = { .input_mapped = ntrig_input_mapped, .usage_table = ntrig_grabbed_usages, .event = ntrig_event, +#ifdef CONFIG_PM + .reset_resume = ntrig_reset_resume, +#endif }; static int __init ntrig_init(void)