From patchwork Sat Jul 28 19:53:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John S Gruber X-Patchwork-Id: 10548055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 094A414E0 for ; Sat, 28 Jul 2018 19:54:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED3B82A889 for ; Sat, 28 Jul 2018 19:54:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1C2F2B187; Sat, 28 Jul 2018 19:54:10 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID, UNPARSEABLE_RELAY 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 9712B2A889 for ; Sat, 28 Jul 2018 19:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730608AbeG1VV0 (ORCPT ); Sat, 28 Jul 2018 17:21:26 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:46013 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730409AbeG1VVZ (ORCPT ); Sat, 28 Jul 2018 17:21:25 -0400 Received: by mail-oi0-f65.google.com with SMTP id q11-v6so14831493oic.12; Sat, 28 Jul 2018 12:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:in-reply-to:references:date:message-id:subject:to; bh=KkAbw+Mw09t7cvlydwjLaLcheYiualng8Isu+fZqHhs=; b=cq9EouqHSVpxSwdgaHg1rQa2D2/CG0RirA4IWRTZvji7k/FXSY2vCf4oV9qCiVBCqr x60OEyKUk2inPREDBA2vqnRfHoqVoG18ldb1HTAV6izPAPXyNKqfhflWEM/J1kOSS1T4 rnzBm+ivO3ORCsW9Ucpr5L53iFQ9ooXC14K7q4gjjuRc5PW/2a0zKWKKNBFwuW1W008H sP4x6hoDPSye7j01VasC1Zi26Al7hCYxLG9k26D/9sURvXvXexAVGaS6Lb6n2IIieSAg axHc6HlPw+emvc1f4YjNqIPZH/3MsxEf8+46JAEfBPxNo74bR/o7o+o0L7KnqvTsDVpA NQpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:in-reply-to:references:date :message-id:subject:to; bh=KkAbw+Mw09t7cvlydwjLaLcheYiualng8Isu+fZqHhs=; b=ZbvgoYQTerhu+m8YC6TlEa9w3rvkAHH4s1mITmRphWLhIQenhdeuXRoS4xgJ1K9s3P rxoOMACO6H9TqdafGnnx6XYjoAsHY/+Ez2jvmv8wZopGZEY2J0G4HMsTjtDtYBgP9Nlg ixo7YN4/iLzaXRv8ws+3l1yH2xjCjHysOrih3MaXK8soYWd/Qv4Ix9/QC8R3UaCBLK7i Gv4y4iILvY2XKv1DsK5T+s/e/xtYARfmM8lcUkohpB72f4HHx0xlEgUJi6PJjmU5nSnT hQCH9/5bmDdDq9dVT0XLqAS2b8Hns+HPf/CwwTPk7kVn+i/DXv2BM6FWSFviHvuf0uo2 Wm/A== X-Gm-Message-State: AOUpUlGG0hWxhKCvHhcx+y++SJYlVQpyvgHEa7mvha0VTo1etK6vNnhh czwn4g8cUjRzV0Zr74/9WWgDODbPcMOaA/UvVdhHYk2q X-Google-Smtp-Source: AAOMgpcXgR4Y+10oOZd+eB//CKSTWtfCT88xhojDWQIE/QuoUUSD7LiSdK55dcTHPTm9rUaSgvd1Lw6CmD8BEGv3TQM= MIME-Version: 1.0 X-Received: by 2002:aca:5c85:: with SMTP id q127-v6mr12518890oib.127.1532807629701; Sat, 28 Jul 2018 12:53:49 -0700 (PDT) Received: from 329980741037 named unknown by gmailapi.google.com with HTTPREST; Sat, 28 Jul 2018 15:53:49 -0400 From: John S Gruber X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532807605-26023-1-git-send-email-JohnSGruber@gmail.com> References: <1532807605-26023-1-git-send-email-JohnSGruber@gmail.com> Date: Sat, 28 Jul 2018 15:53:49 -0400 Message-ID: Subject: [PATCH 1/2] HID: redragon: Fix regression in non-Redragon keyboard due to this new driver To: Jiri Kosina , Robert Munteanu , linux-input@vger.kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org, JohnSGruber@gmail.com 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 The Redragon keyboard uses the second device being presented, but other devices with the same vendor_id/device_id pair (0x0c45:760b) use the first. Don't cause its deletion. Problem introduced in commit 85455dd906d5 ("HID: redragon: Fix modifier keys for Redragon Asura Keyboard") Fixes: 85455dd906d5 Signed-off-by: John S Gruber --- drivers/hid/hid-redragon.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/hid/hid-redragon.c b/drivers/hid/hid-redragon.c index daf5957..85a5fbb 100644 --- a/drivers/hid/hid-redragon.c +++ b/drivers/hid/hid-redragon.c @@ -55,10 +55,6 @@ static int redragon_probe(struct hid_device *dev, return ret; } - /* do not register unused input device */ - if (dev->maxapplication == 1) - return 0; - ret = hid_hw_start(dev, HID_CONNECT_DEFAULT); if (ret) { hid_err(dev, "hw start failed\n"); From patchwork Sat Jul 28 19:53:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John S Gruber X-Patchwork-Id: 10548057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D51B15E2 for ; Sat, 28 Jul 2018 19:54:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CEE12A889 for ; Sat, 28 Jul 2018 19:54:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20DE92AF63; Sat, 28 Jul 2018 19:54:11 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID, UNPARSEABLE_RELAY 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 B86E82AC41 for ; Sat, 28 Jul 2018 19:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730647AbeG1VV2 (ORCPT ); Sat, 28 Jul 2018 17:21:28 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:42368 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730409AbeG1VV1 (ORCPT ); Sat, 28 Jul 2018 17:21:27 -0400 Received: by mail-oi0-f66.google.com with SMTP id n84-v6so14842627oib.9; Sat, 28 Jul 2018 12:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:in-reply-to:references:date:message-id:subject:to; bh=Cyff5ZDAljJB2q/b6oSjpFNPcmyk7DiuV5K1MtrWWIc=; b=CdVE82bfIj4IHTl9H1UGzlXwGFQk0VA+AZE3A9K8HwLgL2TULDaDP2YGurgLxNfWXp 54hKdm5wxO1R1eL7NVeiduSKxXpUgOvDdhg9lYuSjA1uA74QHJr8StITfSNO1n5xCSuU cJ8nYisdJiTXRs0Zmx/pXODkeSRBgQWdg3C9UgRCMZc6rvZBzB50DCMgP+6L0GZAi9ot DjZ3gDo66aHi9aU52XmUZd9rdX0edbCUGs5d+iVWhloTn/5mxq+DTVh7FBQlnkJr6Wl0 TQ46qSFJ8uV9oT1WybsVql7IJpSBaANYbTSHWhvI0uukVsdFbLSrn3HZIXEUwcqgpdIK tXLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:in-reply-to:references:date :message-id:subject:to; bh=Cyff5ZDAljJB2q/b6oSjpFNPcmyk7DiuV5K1MtrWWIc=; b=pJsaeOWz/hCChM+4jnus67bbZ+Kt42n2v6cd0vxvO4tJ5IW9AzG5ApuPEgNixbBB66 kCC8F3taGRb6uEtFS9KD67QnQRmioSQm5IPGbM2RpZ3ZlpXp7f7lmTVJIar3czsGvpLX JWGv9ZC7sfLtXVlFbR7ZuChhcu19mmU6Q8NtQBWCi5Mdd58VMz9N/CgjN33kq+i3Lqme f+ceTGdVmw/DGpIIypRr2VevZmc07yPjPtV/uR4x1TlhI/OrCv9P5IzNEHUp2KoYZO6G bkMaxvb4MTTICMpXGM/qTpDIcpyz9dtSLlsjZCD+cl7qCX5tx9nokJgQumznJYT7YkUX 2p8w== X-Gm-Message-State: AOUpUlF4Gomo9Zy9Qta07nm3sCEhnA31pI2qLYkBuwj+TG6+M7yzpmSJ KoKaCfoJsK3LlwWTJyL+Oh0R1cKrqhPGhdCUREM= X-Google-Smtp-Source: AAOMgpe9ooudiO4UrMj5Kwda7pF++YCs6lL8dWd6qDFRqBs5hkpMXN90dNHgAAvzOPdI81TCcKutrPG6C5k8TofXktQ= MIME-Version: 1.0 X-Received: by 2002:aca:d682:: with SMTP id n124-v6mr12443151oig.32.1532807631580; Sat, 28 Jul 2018 12:53:51 -0700 (PDT) Received: from 329980741037 named unknown by gmailapi.google.com with HTTPREST; Sat, 28 Jul 2018 15:53:51 -0400 From: John S Gruber X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532807605-26023-1-git-send-email-JohnSGruber@gmail.com> References: <1532807605-26023-1-git-send-email-JohnSGruber@gmail.com> Date: Sat, 28 Jul 2018 15:53:51 -0400 Message-ID: Subject: [PATCH 2/2] HID: redragon Add additional verification to rdesc modification quirk To: Jiri Kosina , Robert Munteanu , linux-input@vger.kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org, JohnSGruber@gmail.com 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 There are many devices using the vendor_id 0c45 and device_id of 760b combination. Also the two bytes 0x81 0x00 aren't rare for a report description. For these reasons the report description being altered by the quirk should be verified more completely If I'm understanding this correctly, I believe for an array field the report_size should be greater or equal to ceil(log2(usage_maximum - usage_minimum + 1)). That's 3 bits for these 8 shift keys, 0xe0-0xe7. Therefore the incorrect report description can't be valid for any device. Check the actual count of the rdesc and compare the entire field description to reduce the chance of patching the wrong thing by inadvertence. Signed-off-by: John S Gruber --- drivers/hid/hid-redragon.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-redragon.c b/drivers/hid/hid-redragon.c index 85a5fbb..6e506cb 100644 --- a/drivers/hid/hid-redragon.c +++ b/drivers/hid/hid-redragon.c @@ -18,6 +18,21 @@ #include "hid-ids.h" +static __u8 asura_redragon_badfield[] = { + 0x05, 0x01, /* Usage Page (GenericDesktop) */ + 0x09, 0x06, /* Usage (Keyboard) */ + 0xa1, 0x01, /* Collection (Application) */ + 0x85, 0x04, /* Report ID (4) */ + 0x05, 0x07, /* Usage Page (Keyboard) */ + 0x19, 0xe0, /* Usage Minimum (0xe0) Left Control */ + 0x29, 0xe7, /* Usage Maximum (0xe7) Right GUI */ + 0x15, 0x00, /* Logical Minimum (0) */ + 0x25, 0x01, /* Logical Maximum (1) */ + 0x75, 0x01, /* Report Size (1) */ + 0x95, 0x08, /* Report Count(8) */ + 0x81, 0x00 /* Input Array [Should be Input Var] */ +}; + /* * The Redragon Asura keyboard sends an incorrect HID descriptor. @@ -36,7 +51,9 @@ static __u8 *redragon_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) { - if (*rsize >= 102 && rdesc[100] == 0x81 && rdesc[101] == 0x00) { + if (*rsize == 169 && + memcmp(&rdesc[78], asura_redragon_badfield, + sizeof(asura_redragon_badfield)) == 0) { dev_info(&hdev->dev, "Fixing Redragon ASURA report descriptor.\n"); rdesc[101] = 0x02; }