Received: by 2002:a05:7412:85a1:b0:e2:908c:2ebd with SMTP id n33csp185652rdh; Mon, 30 Oct 2023 19:24:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHM7xjzM658ZBH14N8lvJtN8pwXRhQ3HF1SCKr8/Nizjk68KMV6v7y5aN1AxzfDmIP+TyAC X-Received: by 2002:a05:6358:6f1d:b0:168:e46a:b63 with SMTP id r29-20020a0563586f1d00b00168e46a0b63mr6253422rwn.1.1698719049005; Mon, 30 Oct 2023 19:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698719048; cv=none; d=google.com; s=arc-20160816; b=gSgeuYx+OkXt+b/2E4x2PiKtRCY0GbGTp2qpxaBFSUTrX5PFwBu8wlk/96fcGjISbC ibIpiMpX+a+aidRj5l2mBGNPXg6wYdFlwsoIbmObUILfsFu+7s7V9BztUNcwJxLmqApB ilLOmwpUaZVODWZDK5PvzihbI3b6/Py5i/a6Z4CKhBv2lnnRGrp6z/x1GGl0qLB6rYQF UfbAhZReNTPYefRSKIFexCcXI95a4dAdm5OdwG19dQ+7qMm0rjqpe4vRYCQy7fQskVNN GLrzepMxzIi5TZODcMLlZYfx+QR7Hv+ymE9A1FmQxJHENOGhf7/OgO90SDUbAKuQJ/bj wZsw== 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:subject :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=/JXD693pREHWBy4Dt1P8oq518aZztsASJG12CVDqGd4=; fh=eJFQU6KYNE0KHvwPFc8fKRgg7do57687JXWLRA/Spa4=; b=EtjTUI7EmyfgUg1ZZbyc2Z+b1fOHH6uqxAIavTP3L5VjzhTv6Bdf/qM3E7QOFsvzX3 DYzDxggb+UVgZjcnf0ArESCv8sRivywR8O8zeiVC/8oxWCo9+o5Blqpeen94tw2araaA XAKq/r0EqBZpq51x0CXqrFbyfYtojQj8vJLCi9GuJWfQVBbbvNRnHLy+6MRTIx23II6W kK/yTIkIZb6SQD2QweSce3rfT6P63x4LMwoFtfMPY5Hww8p1F67ctLYOu6yrFmVrtSeH WUgxCna5wgx7VDkFXvpqGDapz0lpJUntr4/hH7Z7OR8JMX9Qj2UQNsY3xVTMKNSePrks Cbvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=VCaxTTHF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id n19-20020a637213000000b005b3594bc4e3si317342pgc.291.2023.10.30.19.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 19:24:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=VCaxTTHF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BA3508046BC3; Mon, 30 Oct 2023 19:24:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231466AbjJaCYB (ORCPT + 99 others); Mon, 30 Oct 2023 22:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjJaCYA (ORCPT ); Mon, 30 Oct 2023 22:24:00 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1901DC5; Mon, 30 Oct 2023 19:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1698719035; bh=/JXD693pREHWBy4Dt1P8oq518aZztsASJG12CVDqGd4=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=VCaxTTHFTKV4VoGo4Xi5uxOiBwUKCxgjJyd6GwaWUpyuWaCznQi6QJfiresw8S0/0 nbj7cG9IwdCosnkBCRagjNwUEP3X5azPRtKFWJBDpCRzttYJaDbeRpfliNWItVEv3c E5yg2WFyUhZj+Z7YWRraaFQwmYC534q+Km/Imgwg= Date: Tue, 31 Oct 2023 03:23:38 +0100 (GMT+01:00) From: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh_?= To: Anshul Dalal Cc: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , linux-input@vger.kernel.org, devicetree@vger.kernel.org, Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jeff LaBundy , Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Message-ID: <9c9f6171-f879-46f5-81d2-6764257a49eb@t-8ch.de> In-Reply-To: References: <20231027051819.81333-1-anshulusr@gmail.com> <20231027051819.81333-2-anshulusr@gmail.com> Subject: Re: [PATCH v6 2/2] input: joystick: driver for Adafruit Seesaw Gamepad MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Correlation-ID: <9c9f6171-f879-46f5-81d2-6764257a49eb@t-8ch.de> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 30 Oct 2023 19:24:06 -0700 (PDT) Oct 31, 2023 03:10:50 Anshul Dalal : > Hello Thomas, > > Thanks for the review! The requested changes will be addressed in the > next patch version though I had a few comments below: > > On 10/27/23 11:44, Thomas Wei=C3=9Fschuh wrote: >> Hi Anshul, >> >> thanks for the reworks! >> >> Some more comments inline. >> >> On 2023-10-27 10:48:11+0530, Anshul Dalal wrote: [..] >>> +struct seesaw_button_description { >>> +=C2=A0=C2=A0 unsigned int code; >>> +=C2=A0=C2=A0 unsigned int bit; >>> +}; >>> + >>> +static const struct seesaw_button_description seesaw_buttons[] =3D { >>> +=C2=A0=C2=A0 { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .code =3D BTN_EAST, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .bit =3D SEESAW_BUTTON_A, >>> +=C2=A0=C2=A0 }, >>> +=C2=A0=C2=A0 { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .code =3D BTN_SOUTH, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .bit =3D SEESAW_BUTTON_B, >>> +=C2=A0=C2=A0 }, >>> +=C2=A0=C2=A0 { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .code =3D BTN_NORTH, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .bit =3D SEESAW_BUTTON_X, >>> +=C2=A0=C2=A0 }, >>> +=C2=A0=C2=A0 { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .code =3D BTN_WEST, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .bit =3D SEESAW_BUTTON_Y, >>> +=C2=A0=C2=A0 }, >>> +=C2=A0=C2=A0 { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .code =3D BTN_START, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .bit =3D SEESAW_BUTTON_START, >>> +=C2=A0=C2=A0 }, >>> +=C2=A0=C2=A0 { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .code =3D BTN_SELECT, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .bit =3D SEESAW_BUTTON_SELECT, >>> +=C2=A0=C2=A0 }, >>> +}; >> >> This looks very much like a sparse keymap which can be implemented with >> the helpers from . >> > > When going through the API provided by sparse-keymap, I could only see > the use for sparse_keymap_report_entry here. Which leads to the > following refactored code: > > static const struct key_entry seesaw_buttons_new[] =3D { > =C2=A0=C2=A0=C2=A0 {KE_KEY, SEESAW_BUTTON_A, {BTN_SOUTH}}, > =C2=A0=C2=A0=C2=A0 {KE_KEY, SEESAW_BUTTON_B, {BTN_EAST}}, No braces I think. > =C2=A0=C2=A0=C2=A0 ... > }; > > for (i =3D 0; i < ARRAY_SIZE(seesaw_buttons_new); i++) { > =C2=A0=C2=A0=C2=A0 sparse_keymap_report_entry(input, &seesaw_buttons_new[= i], > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 data.button_state & BIT(seesaw= _buttons_new[i].code), > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 false); > } > > I don't think this significantly improves the code unless you had some > other way to use the API in mind. I thought about sparse_keymap_setup() and sparse_keymap_report_event(). It does not significantly change the code but would be a standard API. Thomas