linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Korth <gerbilsoft@gerbilsoft.com>
To: David Herrmann <dh.herrmann@googlemail.com>
Cc: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Korth <gerbilsoft@gerbilsoft.com>
Subject: [PATCH 2/2] HID: wiimote: Don't use device IDs for Wii Balance Boards.
Date: Mon, 22 Jun 2020 18:58:11 -0400	[thread overview]
Message-ID: <20200622225811.544-1-gerbilsoft@gerbilsoft.com> (raw)

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


                 reply	other threads:[~2020-06-22 22:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200622225811.544-1-gerbilsoft@gerbilsoft.com \
    --to=gerbilsoft@gerbilsoft.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dh.herrmann@googlemail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).