Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: pxrc - do not store unneeded data in driver structure

There is no need to store data buffer size, pointer to the buffer, or endpoint
address in pxrc structure, as they are either only needed during setup, or are
available from elsewhere.

Reviewed-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Tested-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

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