linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: nintendo: deregister home LED when it fails
@ 2022-04-15 10:04 Icenowy Zheng
  2022-04-18 14:17 ` Silvan Jegen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Icenowy Zheng @ 2022-04-15 10:04 UTC (permalink / raw)
  To: Daniel J . Ogorchock
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel,
	Icenowy Zheng

Some Pro Controller compatible controllers do not support home LED, and
will fail when setting it. Currently this leads to probe failure.

Change the code that fails probing to deregistering home LED.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 drivers/hid/hid-nintendo.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index 2204de889739..ed93287c3afc 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -1900,9 +1900,8 @@ static int joycon_leds_create(struct joycon_ctlr *ctlr)
 		/* Set the home LED to 0 as default state */
 		ret = joycon_home_led_brightness_set(led, 0);
 		if (ret) {
-			hid_err(hdev, "Failed to set home LED dflt; ret=%d\n",
-									ret);
-			return ret;
+			hid_warn(hdev, "Failed to set home LED dflt, unregistering home LED");
+			devm_led_classdev_unregister(&hdev->dev, led);
 		}
 	}
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] HID: nintendo: deregister home LED when it fails
  2022-04-15 10:04 [PATCH] HID: nintendo: deregister home LED when it fails Icenowy Zheng
@ 2022-04-18 14:17 ` Silvan Jegen
  2022-07-20 18:47 ` Nils Helmig
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Silvan Jegen @ 2022-04-18 14:17 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Daniel J . Ogorchock, Jiri Kosina, Benjamin Tissoires,
	linux-input, linux-kernel

Hi

Icenowy Zheng <icenowy@aosc.io> wrote:
> Some Pro Controller compatible controllers do not support home LED, and
> will fail when setting it. Currently this leads to probe failure.
> 
> Change the code that fails probing to deregistering home LED.
> 
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>

Reviewed-by: Silvan Jegen <s.jegen@gmail.com>

I don't have a "Nintendo Pro Controller"-compatible controller to test
with but I have compiled a Kernel with this patch applied and can confirm
that the original Nintendo Pro Controller is still probed correctly with
this patch applied.


Cheers,

Silvan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] HID: nintendo: deregister home LED when it fails
  2022-04-15 10:04 [PATCH] HID: nintendo: deregister home LED when it fails Icenowy Zheng
  2022-04-18 14:17 ` Silvan Jegen
@ 2022-07-20 18:47 ` Nils Helmig
  2022-09-20 22:09 ` Daniel Ogorchock
  2022-09-21  8:57 ` Benjamin Tissoires
  3 siblings, 0 replies; 5+ messages in thread
From: Nils Helmig @ 2022-07-20 18:47 UTC (permalink / raw)
  To: icenowy; +Cc: benjamin.tissoires, djogorchock, jikos, linux-input, linux-kernel

Any updates on this patch? Would like to see this upstream, so that my
8bitdo pro 2 controller can work in switch mode again.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] HID: nintendo: deregister home LED when it fails
  2022-04-15 10:04 [PATCH] HID: nintendo: deregister home LED when it fails Icenowy Zheng
  2022-04-18 14:17 ` Silvan Jegen
  2022-07-20 18:47 ` Nils Helmig
@ 2022-09-20 22:09 ` Daniel Ogorchock
  2022-09-21  8:57 ` Benjamin Tissoires
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Ogorchock @ 2022-09-20 22:09 UTC (permalink / raw)
  To: Icenowy Zheng; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

On Fri, Apr 15, 2022 at 6:06 AM Icenowy Zheng <icenowy@aosc.io> wrote:
>
> Some Pro Controller compatible controllers do not support home LED, and
> will fail when setting it. Currently this leads to probe failure.
>
> Change the code that fails probing to deregistering home LED.
>
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> ---
>  drivers/hid/hid-nintendo.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
> index 2204de889739..ed93287c3afc 100644
> --- a/drivers/hid/hid-nintendo.c
> +++ b/drivers/hid/hid-nintendo.c
> @@ -1900,9 +1900,8 @@ static int joycon_leds_create(struct joycon_ctlr *ctlr)
>                 /* Set the home LED to 0 as default state */
>                 ret = joycon_home_led_brightness_set(led, 0);
>                 if (ret) {
> -                       hid_err(hdev, "Failed to set home LED dflt; ret=%d\n",
> -                                                                       ret);
> -                       return ret;
> +                       hid_warn(hdev, "Failed to set home LED dflt, unregistering home LED");
> +                       devm_led_classdev_unregister(&hdev->dev, led);
>                 }
>         }
>
> --
> 2.35.1
>

Reviewed-by: Daniel J. Ogorchock <djogorchock@gmail.com>

Thanks for the patch. I haven't done any work to make the driver
compatible with non-official nintendo controllers. I suppose there
aren't many other options for controllers lacking full functionality
other than disabling those functions during probe, as demonstrated
here.

-Daniel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] HID: nintendo: deregister home LED when it fails
  2022-04-15 10:04 [PATCH] HID: nintendo: deregister home LED when it fails Icenowy Zheng
                   ` (2 preceding siblings ...)
  2022-09-20 22:09 ` Daniel Ogorchock
@ 2022-09-21  8:57 ` Benjamin Tissoires
  3 siblings, 0 replies; 5+ messages in thread
From: Benjamin Tissoires @ 2022-09-21  8:57 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Daniel J . Ogorchock, Jiri Kosina, linux-input, linux-kernel

On Apr 15 2022, Icenowy Zheng wrote:
> Some Pro Controller compatible controllers do not support home LED, and
> will fail when setting it. Currently this leads to probe failure.
> 
> Change the code that fails probing to deregistering home LED.
> 
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> ---
>  drivers/hid/hid-nintendo.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
> index 2204de889739..ed93287c3afc 100644
> --- a/drivers/hid/hid-nintendo.c
> +++ b/drivers/hid/hid-nintendo.c
> @@ -1900,9 +1900,8 @@ static int joycon_leds_create(struct joycon_ctlr *ctlr)
>  		/* Set the home LED to 0 as default state */
>  		ret = joycon_home_led_brightness_set(led, 0);
>  		if (ret) {
> -			hid_err(hdev, "Failed to set home LED dflt; ret=%d\n",
> -									ret);
> -			return ret;
> +			hid_warn(hdev, "Failed to set home LED dflt, unregistering home LED");

I have s/dflt/default/ and applied to for-6.1/nintendo in hid.git

FWIW, I wondered really hard if we should or not clean up led->name that
devm_kzalloc-ed just a few lines above, but in the end it doesn't add
much to do it now instead of at remove time.

Thanks for the patch and the reviews!

Cheers,
Benjamin

> +			devm_led_classdev_unregister(&hdev->dev, led);
>  		}
>  	}
>  
> -- 
> 2.35.1
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-21  8:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15 10:04 [PATCH] HID: nintendo: deregister home LED when it fails Icenowy Zheng
2022-04-18 14:17 ` Silvan Jegen
2022-07-20 18:47 ` Nils Helmig
2022-09-20 22:09 ` Daniel Ogorchock
2022-09-21  8:57 ` Benjamin Tissoires

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).