diff options
| -rw-r--r-- | drivers/input/joystick/pxrc.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/drivers/input/joystick/pxrc.c b/drivers/input/joystick/pxrc.c index 327b5ef8515f..887a0df9d9a7 100644 --- a/drivers/input/joystick/pxrc.c +++ b/drivers/input/joystick/pxrc.c | |||
| @@ -25,15 +25,13 @@ struct pxrc { | |||
| 25 | struct urb *urb; | 25 | struct urb *urb; |
| 26 | struct mutex pm_mutex; | 26 | struct mutex pm_mutex; |
| 27 | bool is_open; | 27 | bool is_open; |
| 28 | __u8 epaddr; | ||
| 29 | char phys[64]; | 28 | char phys[64]; |
| 30 | unsigned char *data; | ||
| 31 | size_t bsize; | ||
| 32 | }; | 29 | }; |
| 33 | 30 | ||
| 34 | static void pxrc_usb_irq(struct urb *urb) | 31 | static void pxrc_usb_irq(struct urb *urb) |
| 35 | { | 32 | { |
| 36 | struct pxrc *pxrc = urb->context; | 33 | struct pxrc *pxrc = urb->context; |
| 34 | u8 *data = urb->transfer_buffer; | ||
| 37 | int error; | 35 | int error; |
| 38 | 36 | ||
| 39 | switch (urb->status) { | 37 | switch (urb->status) { |
| @@ -61,15 +59,15 @@ static void pxrc_usb_irq(struct urb *urb) | |||
| 61 | } | 59 | } |
| 62 | 60 | ||
| 63 | if (urb->actual_length == 8) { | 61 | if (urb->actual_length == 8) { |
| 64 | input_report_abs(pxrc->input, ABS_X, pxrc->data[0]); | 62 | input_report_abs(pxrc->input, ABS_X, data[0]); |
| 65 | input_report_abs(pxrc->input, ABS_Y, pxrc->data[2]); | 63 | input_report_abs(pxrc->input, ABS_Y, data[2]); |
| 66 | input_report_abs(pxrc->input, ABS_RX, pxrc->data[3]); | 64 | input_report_abs(pxrc->input, ABS_RX, data[3]); |
| 67 | input_report_abs(pxrc->input, ABS_RY, pxrc->data[4]); | 65 | input_report_abs(pxrc->input, ABS_RY, data[4]); |
| 68 | input_report_abs(pxrc->input, ABS_RUDDER, pxrc->data[5]); | 66 | input_report_abs(pxrc->input, ABS_RUDDER, data[5]); |
| 69 | input_report_abs(pxrc->input, ABS_THROTTLE, pxrc->data[6]); | 67 | input_report_abs(pxrc->input, ABS_THROTTLE, data[6]); |
| 70 | input_report_abs(pxrc->input, ABS_MISC, pxrc->data[7]); | 68 | input_report_abs(pxrc->input, ABS_MISC, data[7]); |
| 71 | 69 | ||
| 72 | input_report_key(pxrc->input, BTN_A, pxrc->data[1]); | 70 | input_report_key(pxrc->input, BTN_A, data[1]); |
| 73 | } | 71 | } |
| 74 | 72 | ||
| 75 | exit: | 73 | exit: |
| @@ -124,6 +122,8 @@ static int pxrc_usb_init(struct pxrc *pxrc) | |||
| 124 | { | 122 | { |
| 125 | struct usb_device *udev = interface_to_usbdev(pxrc->intf); | 123 | struct usb_device *udev = interface_to_usbdev(pxrc->intf); |
| 126 | struct usb_endpoint_descriptor *epirq; | 124 | struct usb_endpoint_descriptor *epirq; |
| 125 | size_t xfer_size; | ||
| 126 | void *xfer_buf; | ||
| 127 | unsigned int pipe; | 127 | unsigned int pipe; |
| 128 | int error; | 128 | int error; |
| 129 | 129 | ||
| @@ -136,10 +136,9 @@ static int pxrc_usb_init(struct pxrc *pxrc) | |||
| 136 | return error; | 136 | return error; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | pxrc->bsize = usb_endpoint_maxp(epirq); | 139 | xfer_size = usb_endpoint_maxp(epirq); |
| 140 | pxrc->epaddr = epirq->bEndpointAddress; | 140 | xfer_buf = devm_kmalloc(&pxrc->intf->dev, xfer_size, GFP_KERNEL); |
| 141 | pxrc->data = devm_kmalloc(&pxrc->intf->dev, pxrc->bsize, GFP_KERNEL); | 141 | if (!xfer_buf) |
| 142 | if (!pxrc->data) | ||
| 143 | return -ENOMEM; | 142 | return -ENOMEM; |
| 144 | 143 | ||
| 145 | usb_set_intfdata(pxrc->intf, pxrc); | 144 | usb_set_intfdata(pxrc->intf, pxrc); |
| @@ -154,8 +153,8 @@ static int pxrc_usb_init(struct pxrc *pxrc) | |||
| 154 | if (error) | 153 | if (error) |
| 155 | return error; | 154 | return error; |
| 156 | 155 | ||
| 157 | pipe = usb_rcvintpipe(udev, pxrc->epaddr), | 156 | pipe = usb_rcvintpipe(udev, epirq->bEndpointAddress), |
| 158 | usb_fill_int_urb(pxrc->urb, udev, pipe, pxrc->data, pxrc->bsize, | 157 | usb_fill_int_urb(pxrc->urb, udev, pipe, xfer_buf, xfer_size, |
| 159 | pxrc_usb_irq, pxrc, 1); | 158 | pxrc_usb_irq, pxrc, 1); |
| 160 | 159 | ||
| 161 | return 0; | 160 | return 0; |
