Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp307806rwb; Thu, 18 Aug 2022 04:23:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR6K0XfZNk4fKjro3YrdnAYjWzQyLaCKH61ZqZ7VtC+Fq9ofvzKfThGQq5A3Krzf6GZzu8E8 X-Received: by 2002:a17:906:cc5a:b0:730:8374:7ba5 with SMTP id mm26-20020a170906cc5a00b0073083747ba5mr1628996ejb.144.1660821792811; Thu, 18 Aug 2022 04:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660821792; cv=none; d=google.com; s=arc-20160816; b=Ix/o7i5LfEbNRhTvsLZs4yoVh9dbloFcBz0NQ0ZTTQCXlAKbopeTbrkB4C0fV/hXim 6c+/wr89urMdtZGXBIridqNaMYndWK1sanzN3moO5j6WXB0r24dmY4WB4WtvaHUbv8gh QXxxtJ6/3Vl/QrV6yqcUDbagYkKi4Gs9aqkrUjMOodtpACt//OT7xMQ106/TQ9IyvvPM yuM9c9nRl9eIAsEPzcESlqCPFNf4x4V0GeMhrvJZYM21V66UrlYNKmL1b0rcHMGtQ8b1 LQ280fGQPRNCURJKZ+wl7XRHbNBV3x7nEpS8vbAdXn2DtJL5jD7bYIHVzMsbijiqcpaV 08Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9fVsXAu4P1Mgde2oXVo+acOsn6aaMkcFelHwjHZBtQg=; b=s648961PJBHPFkkhhL+4tKMvtPdos3tURUiRcoEIfkVSq4P/1qXaAu/6iC4j3m4Un7 ZeAGxil86G2bKHxlTf+XyMPjYH0OfReguMcFg3XNkX+8P5oN8tQFddXrts/n8hreR1oc EAQpoYsNtfIWIJs/4udbirdGx5NFBtjRmcze3G178HOWhCAnERBVVs2CFTLymv9M0BZh MetUlypeicjA2JDf/TT9poJVXFbYuRKEdE1n1/S9myfkNNYYYn8qRcy0WZyqiElAQFs8 /wZVaGf37j6LRSrlqOQo4Fq6eBJ7PhylCw5QtS3a2OXXuVx5/RsbSUUcHmyIaok9kTOy Z3Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=ssuAI6l4; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb32-20020a1709076da000b0073156b6fe0esi968125ejc.742.2022.08.18.04.22.46; Thu, 18 Aug 2022 04:23:12 -0700 (PDT) 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=@semihalf.com header.s=google header.b=ssuAI6l4; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244076AbiHRK1t (ORCPT + 99 others); Thu, 18 Aug 2022 06:27:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237435AbiHRK1q (ORCPT ); Thu, 18 Aug 2022 06:27:46 -0400 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66B1D578B4 for ; Thu, 18 Aug 2022 03:27:45 -0700 (PDT) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-333b049f231so29477567b3.1 for ; Thu, 18 Aug 2022 03:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=9fVsXAu4P1Mgde2oXVo+acOsn6aaMkcFelHwjHZBtQg=; b=ssuAI6l4hjntpbmueNgtSHDC29v5f1O+mGRjmyJJv0hT3Uv3KlV9DL3pg/0KKnx+rw ezwUvGh/yZaOrsyyLxhBsEuD3MUR2sXNTrlrkCvnLqO4QW6JCtJ1SHlTKS4iVTXNPzT2 B7FGTaMSiCJAsH6p7nYVp+Yw/dyG3ifNFD3i/kwhUQnD/CARsauUaKmJcB87dQwdqUMQ aD25gvAzwML2DSe2P78IqRWIzTL4eFP+noBGmbo+8mcXMCdOnlVTflATol1Msa+onCry v4ukhOwx5GZu+o7H7GBCFlO5mjQ2chxL2Cxtr+3OwDiw4U1KvziFaJFCLkO2zKW/sRXT oiWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=9fVsXAu4P1Mgde2oXVo+acOsn6aaMkcFelHwjHZBtQg=; b=va5O6FfpXFPcNEOfVduZ+4pDpKvYKqW0SBp/n68IdLj8L9l7DHE+/tEiI3CeCevphB fNtC3p0e/sdlLoXmCnPvoveYdC2bHaa+wR/Cxvr0q8zK818dwCjYarpOFJ6NqquBGKsy C+pTEB4Xm6smyURwl74bRy7jR/nQ50uTZUTrSj8QI80gSDjCCl90z3FQ7V/aZf249+og qLp2eWUn7i1PlBVikEY0afa4rdu979uzpVApceIcdGJgUHrTcq8hY44ZJ0zeDPg9EAiE WGnQ7p4faJxrpbkc1d+FWpKunD6d6xVBHEIwWEYKbDizCjOrRdUwC7MQw/Wf3orp9jRy uMxA== X-Gm-Message-State: ACgBeo3YdzJWaOfLYehbfWfsvhxK8sKb+Z3fcwbjKvIdRmMAbAnpqfbh OT8zxzA3YE2k2ySaa8ukSw1DHCs/kUkG9k3L29/1BQ== X-Received: by 2002:a0d:c981:0:b0:330:dc03:7387 with SMTP id l123-20020a0dc981000000b00330dc037387mr2149397ywd.380.1660818464648; Thu, 18 Aug 2022 03:27:44 -0700 (PDT) MIME-Version: 1.0 References: <20220726080504.4185715-1-tero.kristo@linux.intel.com> In-Reply-To: <20220726080504.4185715-1-tero.kristo@linux.intel.com> From: Angela Czubak Date: Thu, 18 Aug 2022 12:27:33 +0200 Message-ID: Subject: Re: [PATCH] HID: i2c-hid: fix the report-id passed in via set_or_send_report To: Tero Kristo Cc: linux-input@vger.kernel.org, benjamin.tissoires@redhat.com, jikos@kernel.org, linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hi Tero, I believe this is not the right solution. To my mind the spec does not mention anything that the ID in the payload of SET_REPORT command should be altered; you have a full byte to us, so why not? Other than that this will result into problems with sending reports via output register: for any report with report ID >=0xF we will get the same report ID in the payload, so how could the device know which one we have in mind? Dmitry's rework was intended to actually solve problems with large report IDs being incorrectly overwritten with 0xF. Regards, Angela On Tue, Jul 26, 2022 at 10:05 AM Tero Kristo wrote: > > The formatting of the data passed to the i2c HID data register was > changed with the re-work of the i2c-hid-core. Previously the report ID > passed in was encoded as 0xF if the report-id was greater than 0xF > (similar to what is done with the command portion.) Now with the rework, > a full report-id is passed in always, and this causes the messages to be > rejected by the i2c controller. Fix this by encoding the report-id > field in the same manner as previously was done. > > Fixes: dbe0dd5fd2e0 ("HID: i2c-hid: explicitly code setting and sending > reports") > Signed-off-by: Tero Kristo > --- > drivers/hid/i2c-hid/i2c-hid-core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c > index c078f09a2318..156b12f840c4 100644 > --- a/drivers/hid/i2c-hid/i2c-hid-core.c > +++ b/drivers/hid/i2c-hid/i2c-hid-core.c > @@ -296,6 +296,9 @@ static size_t i2c_hid_format_report(u8 *buf, int report_id, > { > size_t length = sizeof(__le16); /* reserve space to store size */ > > + if (report_id > 0xF) > + report_id = 0xF; > + > if (report_id) > buf[length++] = report_id; > > -- > 2.25.1 >