Input: xpad: clean up x360 LED handling
Subsystems (2)
cover Input: xpad: clean up x360 LED handling
From: Pavel Rojtberg <[email protected]>
this series is a follow up to
"[PATCH v2 0/2] Input: xpad: fix 360 wireless controller blinking LEDs" it clarifies the new codepath and removes the now obsolete bulk URB one.
Note that while removing the bulk out URB altogether might seem intrusive, it was only ever used with Xbox 360 wireless Receivers.
Tested on the Xbox 360 Wireless Receiver (PC).
Pavel Rojtberg (2):
Input: xpad: clarify pad nr handling
Input: xpad: remove bulk out URB
drivers/input/joystick/xpad.c | 99 ++++++------------------------------------------------------------ 1 file changed, 9 insertions(+), 90 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 Input: xpad: clarify pad nr handling
From: Pavel Rojtberg <[email protected]>
rename led_no -> pad_nr. update and unify comments.
--- drivers/input/joystick/xpad.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/input/joystick/xpad.c +8 -12
@@ -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 chaif (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 ;
Signature · 1 line
1.9.1
PATCH 2/2 Input: xpad: remove bulk out URB
In reply to Pavel RojtbergFrom: Pavel Rojtberg <[email protected]>
this code is redundand with xpad_send_led_command which does the same thing using irq_out.
It is also misnamed as it is likely to be an irq out and not a bulk out. Furthermore it was probably wrong from the start as setting the LEDs did not work on my x360w controller before fixing xpad_send_led_command in the last patch series.
--- drivers/input/joystick/xpad.c | 79 +----------------------------------------------------------------- 1 file changed, 1 insertion(+), 78 deletions(-)
drivers/input/joystick/xpad.c +1 -78
@@ -328,9 +328,6 @@ struct usb_xpad {unsigned char *idata;/* input data */ dma_addr_t idata_dma; -struct urb *bulk_out; -unsigned char *bdata; -struct urb *irq_out;/* urb for interrupt out report */ unsigned char *odata;/* output data */ dma_addr_t odata_dma;
@@ -510,7 +507,6 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned chaif (data[0 ] &0x08 ) {if (data[1 ] &0x80 ) { xpad->pad_present =1 ; -usb_submit_urb (xpad->bulk_out,GFP_ATOMIC );xpad_identify_controller (xpad); }else xpad->pad_present =0 ;
@@ -668,28 +664,6 @@ exit: __func__, retval); } -static void xpad_bulk_out (struct urb *urb) -{ -struct usb_xpad *xpad = urb->context; -struct device *dev = &xpad->intf->dev; - -switch (urb->status) { -case 0 : -/* success */ -break ; -case -ECONNRESET : -case -ENOENT : -case -ESHUTDOWN : -/* this urb is terminated, clean up */ -dev_dbg (dev,"%s - urb shutting down with status: %d\n" , - __func__, urb->status); -break ; -default : -dev_dbg (dev,"%s - nonzero urb status received: %d\n" , - __func__, urb->status); - } -} -static void xpad_irq_out (struct urb *urb) {struct usb_xpad *xpad = urb->context;
@@ -1215,52 +1189,6 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *idif (xpad->xtype ==XTYPE_XBOX360W ) {/* -* Setup the message to set the LEDs on the -* controller when it shows up -*/ - xpad->bulk_out =usb_alloc_urb (0 ,GFP_KERNEL ); -if (!xpad->bulk_out) { - error = -ENOMEM ; - goto fail7; - } - - xpad->bdata =kzalloc (XPAD_PKT_LEN ,GFP_KERNEL ); -if (!xpad->bdata) { - error = -ENOMEM ; - goto fail8; - } - - xpad->bdata[2 ] =0x08 ; -switch (intf->cur_altsetting->desc.bInterfaceNumber) { -case 0 : - xpad->bdata[3 ] =0x42 ; -break ; -case 2 : - xpad->bdata[3 ] =0x43 ; -break ; -case 4 : - xpad->bdata[3 ] =0x44 ; -break ; -case 6 : - xpad->bdata[3 ] =0x45 ; - } - - ep_irq_in = &intf->cur_altsetting->endpoint[1 ].desc; -if (usb_endpoint_is_bulk_out (ep_irq_in)) { -usb_fill_bulk_urb (xpad->bulk_out, udev, -usb_sndbulkpipe (udev, - ep_irq_in->bEndpointAddress), - xpad->bdata,XPAD_PKT_LEN , - xpad_bulk_out, xpad); - }else { -usb_fill_int_urb (xpad->bulk_out, udev, -usb_sndintpipe (udev, - ep_irq_in->bEndpointAddress), - xpad->bdata,XPAD_PKT_LEN , - xpad_bulk_out, xpad,0 ); - } - -/* * Submit the int URB immediately rather than waiting for open * because we get status messages from the device whether * or not any controllers are attached. In fact, it's
@@ -1270,13 +1198,11 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id xpad->irq_in->dev = xpad->udev; error =usb_submit_urb (xpad->irq_in,GFP_KERNEL );if (error) - goto fail9; + goto fail7; }return 0 ; - fail9:kfree (xpad->bdata); - fail8:usb_free_urb (xpad->bulk_out); fail7:input_unregister_device (input_dev); input_dev =NULL ; fail6:xpad_led_disconnect (xpad);
@@ -1300,8 +1226,6 @@ static void xpad_disconnect(struct usb_interface *intf)xpad_deinit_output (xpad);if (xpad->xtype ==XTYPE_XBOX360W ) { -usb_kill_urb (xpad->bulk_out); -usb_free_urb (xpad->bulk_out);usb_kill_urb (xpad->irq_in); }
@@ -1309,7 +1233,6 @@ static void xpad_disconnect(struct usb_interface *intf)usb_free_coherent (xpad->udev,XPAD_PKT_LEN , xpad->idata, xpad->idata_dma); -kfree (xpad->bdata);kfree (xpad);usb_set_intfdata (intf,NULL );
Signature · 1 line
1.9.1