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

USB: sisusbvga: drop usb_buffer_alloc

This patch falls out of my work to fix usbmon so it uses virtual addresses.
It is not necessary, the "new" usbmon should work just fine with sisusbvga.
However, it seems ridiculous that anyone would use uncached memory to
transfer bulk data. Dropping the unnecessary use of usb_buffer_alloc
should be beneficial here, in case anyone ever uses the dongle on
anything beyond x86.

I had no success in raising the author of the driver by e-mail, so
the patch is not actually tested.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Pete Zaitcev and committed by
Greg Kroah-Hartman
d2fb1bb3 f8086a07

+13 -42
+13 -40
drivers/usb/misc/sisusbvga/sisusb.c
··· 79 79 80 80 for (i = 0; i < NUMOBUFS; i++) { 81 81 if (sisusb->obuf[i]) { 82 - usb_buffer_free(sisusb->sisusb_dev, sisusb->obufsize, 83 - sisusb->obuf[i], sisusb->transfer_dma_out[i]); 82 + kfree(sisusb->obuf[i]); 84 83 sisusb->obuf[i] = NULL; 85 84 } 86 85 } 87 86 if (sisusb->ibuf) { 88 - usb_buffer_free(sisusb->sisusb_dev, sisusb->ibufsize, 89 - sisusb->ibuf, sisusb->transfer_dma_in); 87 + kfree(sisusb->ibuf); 90 88 sisusb->ibuf = NULL; 91 89 } 92 90 } ··· 228 230 229 231 static int 230 232 sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe, void *data, 231 - int len, int *actual_length, int timeout, unsigned int tflags, 232 - dma_addr_t transfer_dma) 233 + int len, int *actual_length, int timeout, unsigned int tflags) 233 234 { 234 235 struct urb *urb = sisusb->sisurbout[index]; 235 236 int retval, byteswritten = 0; ··· 241 244 242 245 urb->transfer_flags |= tflags; 243 246 urb->actual_length = 0; 244 - 245 - if ((urb->transfer_dma = transfer_dma)) 246 - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 247 247 248 248 /* Set up context */ 249 249 sisusb->urbout_context[index].actual_length = (timeout) ? ··· 291 297 } 292 298 293 299 static int 294 - sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data, int len, 295 - int *actual_length, int timeout, unsigned int tflags, dma_addr_t transfer_dma) 300 + sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data, 301 + int len, int *actual_length, int timeout, unsigned int tflags) 296 302 { 297 303 struct urb *urb = sisusb->sisurbin; 298 304 int retval, readbytes = 0; ··· 304 310 305 311 urb->transfer_flags |= tflags; 306 312 urb->actual_length = 0; 307 - 308 - if ((urb->transfer_dma = transfer_dma)) 309 - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 310 313 311 314 sisusb->completein = 0; 312 315 retval = usb_submit_urb(urb, GFP_ATOMIC); ··· 413 422 thispass, 414 423 &transferred_len, 415 424 async ? 0 : 5 * HZ, 416 - tflags, 417 - sisusb->transfer_dma_out[index]); 425 + tflags); 418 426 419 427 if (result == -ETIMEDOUT) { 420 428 ··· 422 432 return -ETIME; 423 433 424 434 continue; 435 + } 425 436 426 - } else if ((result == 0) && !async && transferred_len) { 437 + if ((result == 0) && !async && transferred_len) { 427 438 428 439 thispass -= transferred_len; 429 - if (thispass) { 430 - if (sisusb->transfer_dma_out) { 431 - /* If DMA, copy remaining 432 - * to beginning of buffer 433 - */ 434 - memcpy(buffer, 435 - buffer + transferred_len, 436 - thispass); 437 - } else { 438 - /* If not DMA, simply increase 439 - * the pointer 440 - */ 441 - buffer += transferred_len; 442 - } 443 - } 440 + buffer += transferred_len; 444 441 445 442 } else 446 443 break; 447 - }; 444 + } 448 445 449 446 if (result) 450 447 return result; ··· 507 530 thispass, 508 531 &transferred_len, 509 532 5 * HZ, 510 - tflags, 511 - sisusb->transfer_dma_in); 533 + tflags); 512 534 513 535 if (transferred_len) 514 536 thispass = transferred_len; ··· 3108 3132 3109 3133 /* Allocate buffers */ 3110 3134 sisusb->ibufsize = SISUSB_IBUF_SIZE; 3111 - if (!(sisusb->ibuf = usb_buffer_alloc(dev, SISUSB_IBUF_SIZE, 3112 - GFP_KERNEL, &sisusb->transfer_dma_in))) { 3135 + if (!(sisusb->ibuf = kmalloc(SISUSB_IBUF_SIZE, GFP_KERNEL))) { 3113 3136 dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for input buffer"); 3114 3137 retval = -ENOMEM; 3115 3138 goto error_2; ··· 3117 3142 sisusb->numobufs = 0; 3118 3143 sisusb->obufsize = SISUSB_OBUF_SIZE; 3119 3144 for (i = 0; i < NUMOBUFS; i++) { 3120 - if (!(sisusb->obuf[i] = usb_buffer_alloc(dev, SISUSB_OBUF_SIZE, 3121 - GFP_KERNEL, 3122 - &sisusb->transfer_dma_out[i]))) { 3145 + if (!(sisusb->obuf[i] = kmalloc(SISUSB_OBUF_SIZE, GFP_KERNEL))) { 3123 3146 if (i == 0) { 3124 3147 dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for output buffer\n"); 3125 3148 retval = -ENOMEM;
-2
drivers/usb/misc/sisusbvga/sisusb.h
··· 123 123 int numobufs; /* number of obufs = number of out urbs */ 124 124 char *obuf[NUMOBUFS], *ibuf; /* transfer buffers */ 125 125 int obufsize, ibufsize; 126 - dma_addr_t transfer_dma_out[NUMOBUFS]; 127 - dma_addr_t transfer_dma_in; 128 126 struct urb *sisurbout[NUMOBUFS]; 129 127 struct urb *sisurbin; 130 128 unsigned char urbstatus[NUMOBUFS];