From patchwork Wed Apr 30 21:48:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 4096321 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8ACF7BFF02 for ; Wed, 30 Apr 2014 21:48:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C71A4201F4 for ; Wed, 30 Apr 2014 21:48:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF3F820136 for ; Wed, 30 Apr 2014 21:48:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759440AbaD3Vsp (ORCPT ); Wed, 30 Apr 2014 17:48:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32012 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752219AbaD3Vsp (ORCPT ); Wed, 30 Apr 2014 17:48:45 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3ULmgvC013347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Apr 2014 17:48:42 -0400 Received: from plouf.redhat.com (ovpn-113-179.phx2.redhat.com [10.3.113.179]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3ULmfab031759; Wed, 30 Apr 2014 17:48:41 -0400 From: Benjamin Tissoires To: Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Matthias Bayer Subject: [PATCH] HID: core: fix computation of the report size Date: Wed, 30 Apr 2014 17:48:40 -0400 Message-Id: <1398894520-30407-1-git-send-email-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The extra seven bits are only required when allocating the report buffer. We can not use those extra bytes for the length of the report in the generic implementation of .request because the device might (will) refuse the set_report command. This has been verified on the Atmel touchpad found on the Samsung Ativ 9 plus, which uses hid-multitouch and HID over I2C. Without this fix, the device refuses to switch to the multitouch mode, and it becomes unresponsive from the user point of view. Actually, this has been discussed during the initial submission of the commit 4fa5a7f76cc7b6ac87f57741edd2b124851d119f, see https://patchwork.kernel.org/patch/3621751/ Unfortunately, I completely forgot about it later. Reported-by: Matthias Bayer Signed-off-by: Benjamin Tissoires --- Hi Jiri, can you schedule this fix for 3.15? Fortunately, the device required some ACPI changes, so it was not seen at all in 3.13 and before. I am not sure of the status of 3.14, but it is definitively not working in 3.15. Cheers, Benjamin drivers/hid/hid-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 963a8da..e0f6753 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1253,7 +1253,8 @@ EXPORT_SYMBOL_GPL(hid_output_report); static int hid_report_len(struct hid_report *report) { - return ((report->size - 1) >> 3) + 1 + (report->id > 0) + 7; + /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ + return ((report->size - 1) >> 3) + 1 + (report->id > 0); } /* @@ -1266,7 +1267,7 @@ u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags) * of implement() working on 8 byte chunks */ - int len = hid_report_len(report); + int len = hid_report_len(report) + 7; return kmalloc(len, flags); }