All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Rojtberg <rojtberg@gmail.com>
To: linux-input@vger.kernel.org, pgriffais@valvesoftware.com,
	dmitry.torokhov@gmail.com, gregkh@linuxfoundation.org
Cc: Pavel Rojtberg <rojtberg@gmail.com>
Subject: [PATCH 1/8] Input: xpad: clarify LED enumeration
Date: Sat, 11 Jul 2015 01:47:41 +0200	[thread overview]
Message-ID: <1436572068-10661-2-git-send-email-rojtberg@gmail.com> (raw)
In-Reply-To: <1436572068-10661-1-git-send-email-rojtberg@gmail.com>

From: Pavel Rojtberg <rojtberg@gmail.com>

this one is pure cosmetic, however it helps understanding the code.
1. rename led_no -> pad_nr as the number stored there just gets
translated to a LED nr in xpad_identify_controller
2. move all comments regarding xpad_identify_controller to the function
definition to prevent inconsistent docs.

Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
 drivers/input/joystick/xpad.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index f8850f9..8892daf 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -344,7 +344,7 @@ struct usb_xpad {
 
 	int mapping;			/* map d-pad to buttons or to axes */
 	int xtype;			/* type of xbox device */
-	unsigned long led_no;		/* led to lit on xbox360 controllers */
+	unsigned long pad_nr;		/* the order x360 pads were attached */
 };
 
 /*
@@ -356,7 +356,6 @@ struct usb_xpad {
  *	The used report descriptor was taken from ITO Takayukis website:
  *	 http://euc.jp/periphs/xbox-controller.ja.html
  */
-
 static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
 {
 	struct input_dev *dev = xpad->dev;
@@ -505,7 +504,6 @@ static void xpad_identify_controller(struct usb_xpad *xpad);
  * 01.1 - Pad state (Bytes 4+) valid
  *
  */
-
 static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
 {
 	/* Presence change */
@@ -513,10 +511,6 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
 		if (data[1] & 0x80) {
 			xpad->pad_present = 1;
 			usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
-			/*
-			 * Light up the segment corresponding to
-			 * controller number.
-			 */
 			xpad_identify_controller(xpad);
 		} else
 			xpad->pad_present = 0;
@@ -890,6 +884,7 @@ struct xpad_led {
 };
 
 /**
+ * set the LEDs on Xbox360 / Wireless Controllers
  * @param command
  *  0: off
  *  1: all blink, then previous setting
@@ -942,10 +937,12 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
 	mutex_unlock(&xpad->odata_mutex);
 }
 
+/*
+ * Light up the segment corresponding to the pad number on Xbox 360 Controllers
+ */
 static void xpad_identify_controller(struct usb_xpad *xpad)
 {
-	/* Light up the segment corresponding to controller number */
-	xpad_send_led_command(xpad, (xpad->led_no % 4) + 2);
+	xpad_send_led_command(xpad, (xpad->pad_nr % 4) + 2);
 }
 
 static void xpad_led_set(struct led_classdev *led_cdev,
@@ -971,9 +968,9 @@ static int xpad_led_probe(struct usb_xpad *xpad)
 	if (!led)
 		return -ENOMEM;
 
-	xpad->led_no = atomic_inc_return(&led_seq);
+	xpad->pad_nr = atomic_inc_return(&led_seq);
 
-	snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
+	snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->pad_nr);
 	led->xpad = xpad;
 
 	led_cdev = &led->led_cdev;
@@ -987,7 +984,6 @@ static int xpad_led_probe(struct usb_xpad *xpad)
 		return error;
 	}
 
-	/* Light up the segment corresponding to controller number */
 	xpad_identify_controller(xpad);
 
 	return 0;
-- 
1.9.1


  reply	other threads:[~2015-07-11  7:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10 23:47 [PATCH 0/8] Input: xpad: fix wireless pad connection and URB out Pavel Rojtberg
2015-07-10 23:47 ` Pavel Rojtberg [this message]
2015-07-10 23:47 ` [PATCH 2/8] Input: xpad: remove bulk out URB Pavel Rojtberg
2015-07-10 23:47 ` [PATCH 3/8] Input: xpad: move the input device creation to a new function Pavel Rojtberg
2015-07-10 23:47 ` [PATCH 4/8] Input: xpad: query Wireless controller state at init Pavel Rojtberg
2015-07-30  6:57   ` Dmitry Torokhov
2015-07-10 23:47 ` [PATCH 5/8] Input: xpad: handle "present" and "gone" correctly Pavel Rojtberg
2015-07-30  7:06   ` Dmitry Torokhov
2015-07-10 23:47 ` [PATCH 6/8] Input: xpad: use bitmask for finding the pad_nr Pavel Rojtberg
2015-07-30  6:55   ` Dmitry Torokhov
2015-07-31 12:46     ` Pavel Rojtberg
2015-07-10 23:47 ` [PATCH 7/8] Input: xpad: factor out URB submission in xpad_play_effect Pavel Rojtberg
2015-07-10 23:47 ` [PATCH 8/8] Input: xpad: do not submit active URBs Pavel Rojtberg
2015-07-30  6:59   ` Dmitry Torokhov
2015-07-31 13:08     ` Pavel Rojtberg
     [not found] ` <CA+b0ujev6m0Bpzyj6tJ2-hjf1vudRAkfVyacMb=uV8t6ZKr0dg@mail.gmail.com>
2015-07-25 10:55   ` [PATCH 0/8] Input: xpad: fix wireless pad connection and URB out Pavel Rojtberg

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=1436572068-10661-2-git-send-email-rojtberg@gmail.com \
    --to=rojtberg@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-input@vger.kernel.org \
    --cc=pgriffais@valvesoftware.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.