linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] HID: wiimote: Don't use device IDs for Wii Balance Boards.
@ 2020-06-22 22:58 David Korth
  0 siblings, 0 replies; only message in thread
From: David Korth @ 2020-06-22 22:58 UTC (permalink / raw)
  To: David Herrmann
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel, David Korth

Wii Balance Boards only have a single LED, so the player number can't
be displayed on the board itself. Don't bother allocating a device ID
in this case.

Note that on the actual Wii system, only one board can usually be
connected at a time, and it's listed as Player 4 on the HOME Menu.

Signed-off-by: David Korth <gerbilsoft@gerbilsoft.com>
---
 drivers/hid/hid-wiimote-core.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index 9662c2ce5e99..fc25479028bf 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -834,7 +834,7 @@ static void wiimote_init_set_type(struct wiimote_data *wdata,
 	__u8 leds;
 	__u16 vendor, product;
 	const char *name;
-	int device_id;
+	int device_id = -1;
 
 	vendor = wdata->hdev->vendor;
 	product = wdata->hdev->product;
@@ -882,12 +882,18 @@ static void wiimote_init_set_type(struct wiimote_data *wdata,
 
 	wiimote_modules_load(wdata, devtype);
 
-	/* set player number to stop initial LED-blinking */
-	device_id = ida_simple_get(&wiimote_device_id_allocator, 0, 0,
-				GFP_KERNEL);
+	/* Set player number to stop initial LED blinking.
+	 * Wii Balance Board has a single LED, so don't get
+	 * a player ID for balance boards.
+	 */
+	if (devtype != WIIMOTE_DEV_BALANCE_BOARD)
+		device_id = ida_simple_get(&wiimote_device_id_allocator,
+					0, 0, GFP_KERNEL);
+
 	if (device_id < 0) {
-		/* Unable to get a device ID. */
-		/* Set LED1 anyway to stop the blinking. */
+		/* Unable to get a device ID, or this is a Wii Balance Board.
+		 * Set LED1 anyway to stop the blinking.
+		 */
 		leds = WIIPROTO_FLAG_LED1;
 		wdata->device_id = -1;
 	} else {
-- 
2.27.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-22 22:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 22:58 [PATCH 2/2] HID: wiimote: Don't use device IDs for Wii Balance Boards David Korth

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).