Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2813343rdb; Wed, 4 Oct 2023 12:11:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHH30wIF9CNe9qUcY+37kHs3ENyeQ4q0adu0166vy7+KO6z2ZbvETFNcBPlN4s4PctRD+AC X-Received: by 2002:a17:90a:4584:b0:273:b0bd:343b with SMTP id v4-20020a17090a458400b00273b0bd343bmr2979129pjg.41.1696446667346; Wed, 04 Oct 2023 12:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696446667; cv=none; d=google.com; s=arc-20160816; b=d5wrMQoK8YOi8Jx52J1i3lVIruznW4p4r42/TuMU/aZVMcGXdB1CLubND9OzjMYOLK 17G8XE/zQW5Vg2x9up+vHVwhiPsA1BT2ZnUCq9EeuySmx4hAJCfgbZJ298XoEkwMfKrr 0wvtTcrhFhzLurE/H+ZP7hA353TmHh4ywYBRJ9WZW9v9bxjdm+H/VqF58T2hcauMvMMg ysWm3vs8yCPnlgTuTxuRutM/fy6SIAC+9GeYs2bCfuzErTe9FMZFMHOrInie/3MNuAzA viPyfV++rTm+OETReGByFyPui9JWAHg4rw5GBZYrfAYR2XVFTiFWE5lHKNjIFhWwie2O n/lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=9qxcIVMZtEJ2fzYITnMA0kLg+tv637d2d4WPK2+ez6Y=; fh=HNyBrp7nBXuAShkkF3ZEPgrE0OM2omc7AtF5PqgCEtc=; b=U+QKCJQejleWSyO3FmL/PYetFH4rCtM0uTpBvJxvCRRI2bKjYZrcKtRJqsNeLsiNW8 FbRQON1U8baaGWBo4XzLlbtFt2nhpSDZ4Ph8P68KozpCFWK4dlXkhDCKrbU6OU0nLB2C bcNnh8m15UKg3nVFbC5AatPaH01E8hiunIY/QQwu2HKiC0emqhPqjbsO361IdIIoJKAV ouGryzSHAU89VhdkFw4qmXIBP673hrdRbR+sHe+Zav+2DiT6UHo21R7FIW6VQk6RVdZQ 7/RuuRMWvV2/FYrdUQtcx5JlqS3zp1cdw4rGW173ZNLv45gcfAjfhsiI/H9l+/ZqiyAJ 7kPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="rj3z/u3R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id s23-20020a17090ad49700b0027763f3e3c8si1938970pju.186.2023.10.04.12.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 12:11:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="rj3z/u3R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3162F844D51D; Wed, 4 Oct 2023 12:10:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245545AbjJDTKA (ORCPT + 99 others); Wed, 4 Oct 2023 15:10:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245619AbjJDTJh (ORCPT ); Wed, 4 Oct 2023 15:09:37 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 608A21BF5; Wed, 4 Oct 2023 12:08:14 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA56FC433C8; Wed, 4 Oct 2023 19:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696446494; bh=QNnMLUld3EP0hN/OdAh3qa/KhWWaME+HBFlqQYT6ChM=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=rj3z/u3RnB7WfWljEWfz5tRqCuA4C7ZsQ/PuBNhU7cXWNX2QONvdVNdg4NHIrGP/9 99T5wGqyKjblSKmWNjgA1MUAAcmXxHQR9CBoh68MwyGPjPfQL7gbQ39hODtze55Bet DVtiDvVEBm/Ug107suxPCo+bTxjkLZOO7bzn2H5zElaXxmJiqIWq2hDJlsfnJOsRwp qebDykGKEdzdNSkL/92pM9VIbblpE0nMTUSuiv685jwfFqg1dr0GHqcPbZ4yRDT4Hp fZzB8aIXJ9AXUfQ0Rvd76o+YeLREEF1/ptZzCofhgpmaeHST0/hIZkD4nvbVrFRTIr yleN8q0FN7J0w== Date: Wed, 4 Oct 2023 21:08:10 +0200 (CEST) From: Jiri Kosina To: Martino Fontana cc: djogorchock@gmail.com, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 RESEND] HID: nintendo: cleanup LED code In-Reply-To: <20230924141547.11597-1-tinozzo123@gmail.com> Message-ID: References: <20230924141547.11597-1-tinozzo123@gmail.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 12:10:37 -0700 (PDT) On Sun, 24 Sep 2023, Martino Fontana wrote: > - Support player LED patterns up to 8 players. > (Note that the behavior still consinsts in increasing the player number > every time a controller is connected, never decreasing it. It should be > as is described in https://bugzilla.kernel.org/show_bug.cgi?id=216225. > However, any implementation here would stop making sense as soon as a > non-Nintendo controller is connected, which is why I'm not bothering.) > > - Split part of `joycon_home_led_brightness_set` (which is called by hid) > into `joycon_set_home_led` (which is what actually sets the LEDs), for > consistency with player LEDs. > > - `joycon_player_led_brightness_set` won't try it to "determine which > player led this is" anymore: it's already looking at every LED > brightness value. > > - Instead of first registering the `led_classdev`, then attempting to set > the LED and unregistering the `led_classdev` if it fails, first attempt > to set the LED, then register the `led_classdev` only if it succeeds > (the class is still filled up in either case). > > - If setting the player LEDs fails, still attempt setting the home LED. > (I don't know there's a third party controller where this may actually > happen, but who knows...) > > - Use `JC_NUM_LEDS` where appropriate instead of 4. > > - Print return codes in more places. > > - Use spinlock instead of mutex for `input_num`. Copy its value to a local > variable, so that it can be unlocked immediately. > > - `input_num` starts counting from 0 > > - Less holding of mutexes in general. > > Signed-off-by: Martino Fontana > --- > Changes for v2: > > Applied suggestions, commit message explains more stuff, restored `return ret` > when `devm_led_classdev_register` fails (since all other hid drivers do this). > If setting LED fails, `hid_warn` now explicitly says "skipping registration". > > Changes for v3 and v4: > > Fixed errors and warnings from test robot. > > Changes for v5: > > I thought that when connecting the controller on an actual Nintendo Switch, > only the nth player LED would turn on, which is true... on Wii and Wii U. > So I reverted that, and to compensate, now this supports the LED patterns > up to 8 players. > > drivers/hid/hid-nintendo.c | 133 +++++++++++++++++++++---------------- > 1 file changed, 76 insertions(+), 57 deletions(-) Applied, thank you. -- Jiri Kosina SUSE Labs