Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1010620rwb; Tue, 29 Nov 2022 07:58:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zIJub5QPZ/M0p5+10jYX6fhOz9TYiooGDdchqIsT0QDRDqhuUdGSgR8yiUg5lW0PAwxqX X-Received: by 2002:a17:903:3306:b0:189:7d4d:b9a3 with SMTP id jk6-20020a170903330600b001897d4db9a3mr15206009plb.156.1669737515972; Tue, 29 Nov 2022 07:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669737515; cv=none; d=google.com; s=arc-20160816; b=i0QklDzXPeBDikTmOxf/5avY9EMk8oXeiIpZIRQ7jfxRoO5gYF3OsUTqm98QXu24jF IzxZcApyVZCAUwuVCyf8O2J1z9vnYKJ2W//vgHIWuI2S+opqL+qq2Q9i8gz08QU88bxX 2BHvzSQgymuXcp5PIoxyCpYUGSP/nIVAgREhpJKEcFBggrv11O7Im6aEfG78wiLSAb/C /5jMP4PMZRUqWsTRINoMCI+Iu4vwbd7iuxA/x9JpqQakIOjaqRTswz/XOrN3YUQuGzyL pTc1welP8iaGtzKf6Yis5JdGDXbSJtX4hBwn205HoKMxddXTqfaSEW8dpgq4jeJw/QQW MYlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=OKiMLi5HHOOpw/NEHldLvqrYD5ZLcw1vhetcd+gYz98=; b=aqV66t0WtXO2Y5xfz8r0Gb8FxcRJ+mQA5sTAa5jlYNyMoBnbXIjoc/m4f8i8eRlsEw 0VzGZMXRNmigBRmZjPCiTOAf13sM3W2OMbsWNDcOT908ehTa1IWWEqLDxnmPUTKZt3XR /3YxKR0+GK/mmdxBO+Rgb1zE035mRJlFAxREKUvm56nV3RWpP49K2TgUOqLfp1uJWjFd i3jPEyGdN1tVdlwwTSNCLxYH9bGTjAk92jaPBeEXEw5vd/MljoqAGZzrpvkB9ckiAq5x T41aA8Kp2SSyr15FAiVJNn8jPeL/B4Q1vaoAEKD5vfyYDor6Bx8Fy2/ci6Ra2bfqHLce Ogkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c9q1Apte; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jo6-20020a170903054600b0018996404dd9si3284333plb.267.2022.11.29.07.58.24; Tue, 29 Nov 2022 07:58:35 -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=@kernel.org header.s=k20201202 header.b=c9q1Apte; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235828AbiK2Pjj (ORCPT + 84 others); Tue, 29 Nov 2022 10:39:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234931AbiK2Pjg (ORCPT ); Tue, 29 Nov 2022 10:39:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 507981CB0C; Tue, 29 Nov 2022 07:39:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E1930617A5; Tue, 29 Nov 2022 15:39:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B46DC433C1; Tue, 29 Nov 2022 15:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669736375; bh=3WvpfKAMMBXTqgD9OElc2LMfZiGvyFTgYTlwBSpfPUA=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=c9q1ApteullDnEXtba85UEGzFJ5a/cjyrIbSsgP3eENCfn7eovuS5qxLAvcB+bVBE rJ4wTjQKWkiemyXd0GXENy+T1bg6BaqE5yvNaafX/JiCrby6WAkFdVA5Ky4haHXMTL u9QbnI3J60WuMxrPVAunA0oUt84VwSPgz3blJKYvTP0i8TUamEIxm31NbJhOyOL1OH 7FTefHvFJYHOiS4Q3AgaixZh5zbSf5cWSqdzXVpU24tmvUZZ31zz0lg/QYeL1/HYIe 8naJaG677gMStMZtpR6NuTOgWB5Itn3oXOWIV5NPJRjnfOpAE9rAuQVpN9cw/WKCBa KjXkzNw2i3dLA== Date: Tue, 29 Nov 2022 09:39:33 -0600 From: Bjorn Helgaas To: Lars Povlsen Cc: Rishi Gupta , Jiri Kosina , Benjamin Tissoires , UNGLinuxDriver , linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Takayuki 'January June' Suwa Subject: Re: [PATCH] HID: mcp2221: Fix GPIO output handling Message-ID: <20221129153933.GA716319@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201104220223.293253-1-lars.povlsen@microchip.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 [+cc Takayuki, thanks for your report!] On Wed, Nov 04, 2020 at 11:02:23PM +0100, Lars Povlsen wrote: > The mcp2221 driver GPIO output handling has has several issues. > > * A wrong value is used for the GPIO direction. > > * Wrong offsets are calculated for some GPIO set value/set direction > operations, when offset is larger than 0. > > This has been fixed by introducing proper manifest constants for the > direction encoding, and using 'offsetof' when calculating GPIO > register offsets. > > The updated driver has been tested with the Sparx5 pcb134/pcb135 > board, which has the mcp2221 device with several (output) GPIO's. > > Signed-off-by: Lars Povlsen > --- > drivers/hid/hid-mcp2221.c | 48 +++++++++++++++++++++++++++++++-------- > 1 file changed, 39 insertions(+), 9 deletions(-) > > diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c > index 0d27ccb55dd9..4211b9839209 100644 > --- a/drivers/hid/hid-mcp2221.c > +++ b/drivers/hid/hid-mcp2221.c > +/* MCP GPIO get command layout */ > +struct mcp_get_gpio { > + u8 cmd; > + u8 dummy; > + struct { > + u8 direction; > + u8 value; > + } gpio[MCP_NGPIO]; > +} __packed; This bug report: https://bugzilla.kernel.org/show_bug.cgi?id=216736 suggests that direction and value may be reversed here. Mentioning here in case nobody actively monitors the bugzilla. Bjorn