Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6537023rwb; Mon, 5 Dec 2022 13:55:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Hc6jjdZgO2vb3OmLIRZ1zkPnxmWQWYp3jr+jYFds+UHejwvDJ/MFbZXqBIFVum7XMot65 X-Received: by 2002:a17:906:4f0c:b0:7c0:fd1a:6792 with SMTP id t12-20020a1709064f0c00b007c0fd1a6792mr3581372eju.431.1670277330934; Mon, 05 Dec 2022 13:55:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670277330; cv=none; d=google.com; s=arc-20160816; b=x7skU2vBbA0j5L97JEfXeD8rLaAhR8gwgdN5hbKXkbA6CqM+4d4qddBfdoLwfuWTFt v9vIJocUilckw0AqejGO3NNq5N8qPqYGCa/rDOGbAP3vnsxM7ugUoHaT35NCd81DZO65 FjntzujOHY4YvEfhgs2E3RYOrwd37od04WHFimR0kvLPbCqokdt4PXf+Y5fcXst1Efgs qhjAN/K6cn2vq7Gf7Gp9vgee2BSCfduG4GZ4WzTA9Z/3CJ00NvRZBJrfxbaMH837lEVJ Gj4Cq2wi153slGWyjxjV9GhlFqeyRUzwQwC7ipG/xzl9Th/8zbcTrWnLVj6/Pb8UkNdA u4uQ== 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=w6oMfPCt+VzMyZOzVwetr+D2O/Sy+iM3cliiKh9kVZk=; b=RFA0rXtKPB1FiwY5C1IK7dyNOZfGxmyPRX4zkhg7Xj+EM3WETbAyTX+iVdig2glpxm A5XaIoNH2k1ktTQ9cNUibMGX6SpMGsCXjLTgdGnILtevXyiHPkNPz8zwqxDq5VTWjS/X 0ufhdoIbmLO/BwXHiMxwrWYhcCTuLbffVyP6Z44EDts/JDj5CBUo2wVVyDrvvuYRpnVM 3sCYVbhtc0BJ3U/i80sYguXOpLKSsB3Rw+MDSIb2OMnj5zSeJhh0OLi3Y/gY5CnRaS16 Q0nF7f/Jul+uCfw1yTySv1PLvZ3xB6XB7at9jxWehCjREQvG7gAWeITg8ptOqOGj7oYW Qqgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JuM7gtZP; 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 m8-20020a50ef08000000b0046ae9e1f92dsi440873eds.180.2022.12.05.13.55.10; Mon, 05 Dec 2022 13:55:30 -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=JuM7gtZP; 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 S230327AbiLEVF0 (ORCPT + 80 others); Mon, 5 Dec 2022 16:05:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233834AbiLEVEs (ORCPT ); Mon, 5 Dec 2022 16:04:48 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FEDD2B27C; Mon, 5 Dec 2022 13:04:19 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so4115941pjj.2; Mon, 05 Dec 2022 13:04:19 -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=w6oMfPCt+VzMyZOzVwetr+D2O/Sy+iM3cliiKh9kVZk=; b=JuM7gtZPmUahPjEzpRJ/D0IW/rRSE5knEYmUm5AwygVdwzx6Vg56SynSTVXmZ+YUPy nfCONatVNQI5AHc5dUKtRL5s6hab06jjg07/RSdZptm6KqoYEGdR6ltqROa5On7BN7eY /jUwDaaCcDqABPUXjvKjh8N8RKTSV4m7JdvQQQ+MhBVHZGDPMhx9uLrDJlYkr2rKnHde s4kn+/5GoRHQ3S33uQGqld26AkN7q8BTlQ7wPUkm+oFuAQm1mnzenf/GuHD6B3GI9gaF KsLKeUIU3Fr4CWM6fTDE4jDMKZPPlEpiUEOl23GfmGahGmzVrlcsI9nRtRwwaBdXeuxF 8VFA== 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=w6oMfPCt+VzMyZOzVwetr+D2O/Sy+iM3cliiKh9kVZk=; b=Tfh9UeVjGpm3Ti5Kpds7RonyINADtphYhBZfEPHfz7Ew9umeINIwpEHb4yTGQ1v573 P0LzlZEcgiqapBDqheCiWcirQX17kIDBFc6srC1mjNhomoeTfMAhEBZy69bTH0X6WOfH cnIyTC+GcEQY/SEwOebtEb27w+m1Pibs9Msmkkw8HUbv/Mkf2iO1LAglPhe2OH8mqZru VxTx1J7f+I991eYHzpNlAUXtacvPhplt3GZlwYaHEeElSA+OneHeRb21mQy5zRFxb8hr RbJ/1hK/31pAF9YRrbA8k/E5B0xwfyv1rcvZFgUGZjuTbsK/hoyFa7J4e+GBWWk4mhzo tDTw== X-Gm-Message-State: ANoB5plf2OW33Qaw8xk4PfGSl8QQEDh2Fo1QhOFbJXeqi5ySRvxe0nth y64ts9xSzzRyO4GKXiCSRkPOK9n//Ck= X-Received: by 2002:a17:902:d550:b0:189:7bfe:1eb5 with SMTP id z16-20020a170902d55000b001897bfe1eb5mr22835674plf.9.1670274258003; Mon, 05 Dec 2022 13:04:18 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 13:04:17 -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 1/2] HID: uhid: Don't send the report ID if it's zero Date: Mon, 5 Dec 2022 13:03:53 -0800 Message-Id: <20221205210354.11846-2-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 handling ID-less reports and in that case we should omit report ID from the payload being sent to the backend. Without this change UHID_DEV_NUMBERED_{FEATURE,OUTPUT}_REPORTS doesn't represent a semantical difference. 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/uhid.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 2a918aeb0af1..7551120215e8 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c @@ -273,11 +273,11 @@ static int uhid_hid_get_report(struct hid_device *hid, unsigned char rnum, } static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum, - const u8 *buf, size_t count, u8 rtype) + u8 *buf, size_t count, u8 rtype) { struct uhid_device *uhid = hid->driver_data; struct uhid_event *ev; - int ret; + int ret, skipped_report_id = 0; if (!READ_ONCE(uhid->running) || count > UHID_DATA_MAX) return -EIO; @@ -286,6 +286,15 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum, if (!ev) return -ENOMEM; + /* Byte 0 is the report number. Report data starts at byte 1.*/ + buf[0] = rnum; + if (buf[0] == 0x0) { + /* Don't send the Report ID */ + buf++; + count--; + skipped_report_id = 1; + } + ev->type = UHID_SET_REPORT; ev->u.set_report.rnum = rnum; ev->u.set_report.rtype = rtype; @@ -306,7 +315,7 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum, if (uhid->report_buf.u.set_report_reply.err) ret = -EIO; else - ret = count; + ret = count + skipped_report_id; unlock: mutex_unlock(&uhid->report_lock); -- 2.34.1