Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6581981rwb; Mon, 5 Dec 2022 14:39:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4w2Wv964UOSG2fKDscU1hr02zZTZAKedWHCtUA2LfGqvhI+f5bkPi0In6LTrOTdUqyV8M9 X-Received: by 2002:a17:907:d412:b0:7bc:68cc:7913 with SMTP id vi18-20020a170907d41200b007bc68cc7913mr43110493ejc.589.1670279986047; Mon, 05 Dec 2022 14:39:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670279986; cv=none; d=google.com; s=arc-20160816; b=Zlxtix8RJv4wc6f1bOLsRH58FFTa+8NhmIyLVas5QmRvfPUkBnTjnj3iW+wRIyzyS/ d2MfcG74GFbJ6p5Ct0dnt67sSHrco14qBY0QvzpZoETqCVIOm1D3Q6u+SceVT/y9R83b igycTlAYFrimy85zPmhDc7QRXQlVtvZhADcqLDyOA+OZ+SgA9EMQFvgI43BwQ+yby7LD j8zkC5BlVp6nrYqdNWmsgtVTBYaTmgIe22gv2wt2ebjxpvqTa3SrK/uBtrnVyZeJ7lW7 JXrLPBrLpiTW8WYpu5gz343I4odxgSREUgrsAHp406h+yhpndbIx3ThwNiI61UcY90zH 2XWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TpZoCNuVtqWmqXfOBYxoJCLHU/tCYzYlfr7fdZ1HLBU=; b=QjOVJkxiIsCPe+o+73xw0OZuSCyc0Q4d0cGdmBaIv7qqDGbD+7mIxjsseNXfYrnjXS RtRfYg5jB1b3Wmpbj45FBsszYY8BrjE9XJmjxTWdT0u2vDSYd4yRiag7bmILulSPnrZ8 IJ9Tp+0xzY1QPUmtvHwtVJkGZJ/dWhIwUpsy5UMSmMDtrjgGFjVzkG+vZOpLlTHlAsgM 66n9jZt+icV0MPVEbuBxMEQiIQc27PDXQ9PIlCY8oQ46kB04ITji10CKKv3JLIyCoZIh 6X+xMKUrcaxPUMnjKONu5ZKZzupiSd4HHXQxjx90+4c9p5ZW04DRIqFqn7DJEXu9MeVg jF8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="PC0oDyi/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s22-20020a056402521600b0046b1abd7876si657748edd.535.2022.12.05.14.39.27; Mon, 05 Dec 2022 14:39:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="PC0oDyi/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233268AbiLEVFb (ORCPT + 80 others); Mon, 5 Dec 2022 16:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233708AbiLEVEs (ORCPT ); Mon, 5 Dec 2022 16:04:48 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 173CB10F; Mon, 5 Dec 2022 13:04:21 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id c13so5505490pfp.5; Mon, 05 Dec 2022 13:04:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TpZoCNuVtqWmqXfOBYxoJCLHU/tCYzYlfr7fdZ1HLBU=; b=PC0oDyi/tmGrc1uhDSRSEHyMY+H+R9uB+dmHF3Y35EYWmpVS2VY+Xrv+sssREll6lq KttFq0viN82AH9/OKk8DWaa5QQK5ITu/FGFnPaWo9T5LoNcWu4JgQ/t7xCCmrcFH/YqH ga0N38vcc6CnlDsoxLkPblh8QNaxgUeBdq48dpKPheV6rGGoymBeHbxEYLJykrEqyvnx taVNEOLElceyej6h+5pnu+EXV1mO/UBcm0nW7pzjXmi15UfUryXUkLjuufdfbShiAjYf L++8MxBQTBq4c7EwPMxFF0V1lCVC19SK/3ArAuunrKXHJhV1ub+9rk8sTm/wuR9MxKUV hiMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TpZoCNuVtqWmqXfOBYxoJCLHU/tCYzYlfr7fdZ1HLBU=; b=V7MrBsWYPCjhQRkotbS3yDL4rOl1zi4xbIcnf+bVupPNVrvq8i+RPzkmvUXdziyyQU gtXsPuYmnZLw1mi32NPo0AqRpK7jFDPTCQ/LfX5HywOmclwqsDsxPv8fRUryPyjO5aQO UJ/50/LHd/+hDw8FbDn/drycsB+U0mgefWOdYbth6XpXGMnnx1EB8M1FbdNPrht40Fnw Pfl0tEi9RxDMf/yvvtYszg0IA6PR7b2Dh4tGjz9ymBvSALiMjWW5Pp+b41m/HY2+KOn5 PfM+DFnZMg8dqNJZMwDSJYBDYmTaV8NOCVTsY+m3J3glwov/XJm7w6wY+ykuJSVE/RFT UobQ== X-Gm-Message-State: ANoB5pkpbsOxs55nzua0L2xwpA3PUtFIMoGTUu1IK+/RygB7ADYQJrkI LitVxDpUXgKz3DHmVnl/TvEi+OLBKjM= X-Received: by 2002:a63:ea17:0:b0:477:9a46:f57b with SMTP id c23-20020a63ea17000000b004779a46f57bmr58686536pgi.319.1670274260086; Mon, 05 Dec 2022 13:04:20 -0800 (PST) Received: from charizard.lan (c-67-183-167-205.hsd1.wa.comcast.net. [67.183.167.205]) by smtp.gmail.com with ESMTPSA id b13-20020a170903228d00b0017ec1b1bf9fsm3209863plh.217.2022.12.05.13.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 13:04:19 -0800 (PST) From: Andrey Smirnov To: linux-input@vger.kernel.org Cc: Andrey Smirnov , David Rheinsberg , Jiri Kosina , Benjamin Tissoires , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [RFC PATCH 2/2] HID: usbhid: Don't include report ID zero into returned data Date: Mon, 5 Dec 2022 13:03:54 -0800 Message-Id: <20221205210354.11846-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221205210354.11846-1-andrew.smirnov@gmail.com> References: <20221205210354.11846-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Report ID of zero is a special case for ID-less reports, which by definition do not have report ID as a part of their payload. Not returning an extra zero also matches hidraw documentation, specifically: For devices which do not use numbered reports, set the first byte to 0. The returned report buffer will contain the report number in the first byte, followed by the report data read from the device. For devices which do not use numbered reports, the report data will begin at the first byte of the returned buffer. Cc: David Rheinsberg Cc: Jiri Kosina Cc: Benjamin Tissoires Cc: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-usb@vger.kernel.org Signed-off-by: Andrey Smirnov --- drivers/hid/usbhid/hid-core.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index be4c731aaa65..575f09003602 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -874,18 +874,8 @@ static int usbhid_get_raw_report(struct hid_device *hid, struct usb_device *dev = hid_to_usb_dev(hid); struct usb_interface *intf = usbhid->intf; struct usb_host_interface *interface = intf->cur_altsetting; - int skipped_report_id = 0; int ret; - /* Byte 0 is the report number. Report data starts at byte 1.*/ - buf[0] = report_number; - if (report_number == 0x0) { - /* Offset the return buffer by 1, so that the report ID - will remain in byte 0. */ - buf++; - count--; - skipped_report_id = 1; - } ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), HID_REQ_GET_REPORT, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, @@ -893,10 +883,6 @@ static int usbhid_get_raw_report(struct hid_device *hid, interface->desc.bInterfaceNumber, buf, count, USB_CTRL_SET_TIMEOUT); - /* count also the report id */ - if (ret > 0 && skipped_report_id) - ret++; - return ret; } -- 2.34.1