Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp675748rdb; Tue, 31 Oct 2023 21:22:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxGbP/Yl16doPtsH9dcwBkma5Ct1kIx39zUAbYb0psJUVmZ9LToEt0XQHNKZGLxAr0EqZk X-Received: by 2002:a17:902:efc9:b0:1ca:20a0:7b08 with SMTP id ja9-20020a170902efc900b001ca20a07b08mr14217445plb.50.1698812548345; Tue, 31 Oct 2023 21:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698812548; cv=none; d=google.com; s=arc-20160816; b=gJ9lMuJDEJJdiVDKAkWYgDL2grAQTNbFjo545RBS/n5x+UnC8sbejvO6+OtND5BBZ5 421XyxElayv+mP3yQrJXPbEhPezeV1VdQKAQjRuQ3ssMl/MoKXJHNv66UiQZFLF5HSHu kCbmiZ4smFbk+AXyNVIuWKEK+gsfw1F61L0uKuVFtk5OmKXdPVHHR7S3XXHy+IO6MFUx vSN+A4fCthSlie6UGpbdXD8EO/qeBgnRSgUfkc8anKdXEI2ar2RlXsE5euRCVSk6Kiy+ BdJyD/Y44KsqI1TsCliv+BiZHOaVPciOZDZZK3J6B7ZG2YrYEMCmhMYyUhDlxlwkusrc M0+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=pZje7TQ/ZEluQMkAlttorTMy20pqANNs00Qqi1mxzH4=; fh=XUOvSync2dIJACuoECWXIEbpYrGnM9IgigmKdeCBy1s=; b=vjEWijbTua6joV+wXAjDkkLL+sRk5yz034dZDLLj2Ul+vRzMeXaNhnbq+TIZyS392z hY9HeRKCOyrvkr1UAJ4JtzniQc8nsGj3nfhZlUMJQtYKn4FjNrvWZiu7vKjHOYswkS25 4569DA4HaKuTkJmbvgUD1siHJ+2ux35i1smnAFZBT6GqbveK4QBZIP48vqryfDhHf3RQ rmxm+LRdqQZKvgOSWI0hO8qZVFhFeidXMnGx/mfkB5QfhvrX6vEjiU2YBcwp3BdfzALz 0JvtUBCtP6ITFzy+DFKDIi3X4CJz+vysYBcNx57M6szAtQT3w7Abk24H0t1TRZeF3U5r +Gow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VsDiDbBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id y2-20020a170902cac200b001bb9e2c38ecsi2050495pld.264.2023.10.31.21.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 21:22:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VsDiDbBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D56D680FCBCA; Tue, 31 Oct 2023 21:22:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344729AbjKAEWF (ORCPT + 99 others); Wed, 1 Nov 2023 00:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236299AbjKAEWD (ORCPT ); Wed, 1 Nov 2023 00:22:03 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BBCDB7; Tue, 31 Oct 2023 21:21:59 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6be1bc5aa1cso6521529b3a.3; Tue, 31 Oct 2023 21:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698812519; x=1699417319; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=pZje7TQ/ZEluQMkAlttorTMy20pqANNs00Qqi1mxzH4=; b=VsDiDbBhoedvNfWpJ9FsnKT8DqpS+ni+TFuW5dk52S2iijrMNvrBHBUHDV/0Ze18vA fcQlG9LezqvzrP/pXx1fi/SLaEoOrTSJEJtNHVFgLwztiElmc/Jrt4Ob46OfFU21c/rH 8kfEM4x2NEn/c0mMfTQTqAgZ8MC1vKwZTUGjLhI3Jg9HXbHcEW/zGQeZqwGsv+MN1h35 x48EhOHSHp3kVQ1keOpSfezyYBj/YsDgMwesi66A0yzw3GGj1CXK8AWFPwe8PJqUuDPl dAdXZ6pshHDf+rgCBc1Tu5+nzE4z+Ik1xvbgsCQVqQPDY+JzHHKH1unfsdRd0hgHtGXi +FDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698812519; x=1699417319; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pZje7TQ/ZEluQMkAlttorTMy20pqANNs00Qqi1mxzH4=; b=KBbhv2FqTk5aiRsZ9RHKWvxyeCSlu7DAG4CVtCebhETcWi34V41ipsrwjRiLMX1j0K dJqpl38HU6MfZtdxSKfpfws9jYhMYZJs3CHAuTgE4MGXsZN4xiIiulAuiwjOu4LR7WSg 31Cl6kuCjmQedSgFL2S87PZd8THtW/07x4ZTQY574nlHWhIV8JPpNg/dpaXK3XzKBO7f iROSEoMjXSN6NI/BUO4XKWP6pmhTdVCBN1sU+npnSb6+gIGSbE1XaHAdlYquBKCB4Ff6 sfiY7gw4tD/uhIPMbJSxsuO485zwo18J9lo1OL/HXD3rogEaa8oFRJ9pNqO1LqwLUa/0 WolA== X-Gm-Message-State: AOJu0YwdhtdRbIGlgXgwKnBsid+pNdngAFw/D1iheO8qSQqzDBXl6KKv WvoMKwHDFGl1ejATR58t6T8= X-Received: by 2002:a05:6a20:1587:b0:15d:b243:6131 with SMTP id h7-20020a056a20158700b0015db2436131mr18156809pzj.44.1698812518745; Tue, 31 Oct 2023 21:21:58 -0700 (PDT) Received: from ?IPV6:2401:4900:6274:7b8d:58b:47c1:d32d:b04a? ([2401:4900:6274:7b8d:58b:47c1:d32d:b04a]) by smtp.gmail.com with ESMTPSA id m11-20020a1709026bcb00b001c5eb2c4d8csm354261plt.160.2023.10.31.21.21.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Oct 2023 21:21:58 -0700 (PDT) Message-ID: <152d15c4-10bb-45fe-9b9c-b323535a921f@gmail.com> Date: Wed, 1 Nov 2023 09:50:36 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 2/2] input: joystick: driver for Adafruit Seesaw Gamepad Content-Language: en-US To: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= 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 References: <20231027051819.81333-1-anshulusr@gmail.com> <20231027051819.81333-2-anshulusr@gmail.com> <9c9f6171-f879-46f5-81d2-6764257a49eb@t-8ch.de> From: Anshul Dalal In-Reply-To: <9c9f6171-f879-46f5-81d2-6764257a49eb@t-8ch.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Tue, 31 Oct 2023 21:22:24 -0700 (PDT) On 10/31/23 07:53, Thomas Weißschuh wrote: > 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ßschuh 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 { >>>> +   unsigned int code; >>>> +   unsigned int bit; >>>> +}; >>>> + >>>> +static const struct seesaw_button_description seesaw_buttons[] = { >>>> +   { >>>> +       .code = BTN_EAST, >>>> +       .bit = SEESAW_BUTTON_A, >>>> +   }, >>>> +   { >>>> +       .code = BTN_SOUTH, >>>> +       .bit = SEESAW_BUTTON_B, >>>> +   }, >>>> +   { >>>> +       .code = BTN_NORTH, >>>> +       .bit = SEESAW_BUTTON_X, >>>> +   }, >>>> +   { >>>> +       .code = BTN_WEST, >>>> +       .bit = SEESAW_BUTTON_Y, >>>> +   }, >>>> +   { >>>> +       .code = BTN_START, >>>> +       .bit = SEESAW_BUTTON_START, >>>> +   }, >>>> +   { >>>> +       .code = BTN_SELECT, >>>> +       .bit = SEESAW_BUTTON_SELECT, >>>> +   }, >>>> +}; >>> >>> 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[] = { >>     {KE_KEY, SEESAW_BUTTON_A, {BTN_SOUTH}}, >>     {KE_KEY, SEESAW_BUTTON_B, {BTN_EAST}}, > > No braces I think. > Since the last field in key_entry is a union, the braces seem to be required. >>     ... >> }; >> >> for (i = 0; i < ARRAY_SIZE(seesaw_buttons_new); i++) { >>     sparse_keymap_report_entry(input, &seesaw_buttons_new[i], >>         data.button_state & BIT(seesaw_buttons_new[i].code), >>         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. > Thanks for pointing me in the right direction, do you think the following implementation of the API is acceptable for the driver. Since I couldn't find a driver for any similar device using the API in this manner. inside seesaw_probe(): err = sparse_keymap_setup(seesaw->input_dev, seesaw_buttons_new, NULL); if (err) { dev_err(&client->dev, "failed to set up input device keymap: %d\n", err); return err; } inside seesaw_poll(): for (i = 0; i < ARRAY_SIZE(seesaw_buttons_new); i++) { if (!sparse_keymap_report_event( input, seesaw_buttons_new[i].code, data.button_state & BIT(seesaw_buttons_new[i].code), false)) { dev_err_ratelimited( &input->dev, "failed to report event for keycode: %d", seesaw_buttons_new[i].keycode); return; } } > Thomas Best regards, Anshul