Commit d2fb1bb3 authored by Pete Zaitcev's avatar Pete Zaitcev Committed by Greg Kroah-Hartman

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: default avatarPete Zaitcev <zaitcev@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f8086a07
...@@ -79,14 +79,12 @@ sisusb_free_buffers(struct sisusb_usb_data *sisusb) ...@@ -79,14 +79,12 @@ sisusb_free_buffers(struct sisusb_usb_data *sisusb)
for (i = 0; i < NUMOBUFS; i++) { for (i = 0; i < NUMOBUFS; i++) {
if (sisusb->obuf[i]) { if (sisusb->obuf[i]) {
usb_buffer_free(sisusb->sisusb_dev, sisusb->obufsize, kfree(sisusb->obuf[i]);
sisusb->obuf[i], sisusb->transfer_dma_out[i]);
sisusb->obuf[i] = NULL; sisusb->obuf[i] = NULL;
} }
} }
if (sisusb->ibuf) { if (sisusb->ibuf) {
usb_buffer_free(sisusb->sisusb_dev, sisusb->ibufsize, kfree(sisusb->ibuf);
sisusb->ibuf, sisusb->transfer_dma_in);
sisusb->ibuf = NULL; sisusb->ibuf = NULL;
} }
} }
...@@ -230,8 +228,7 @@ sisusb_bulk_completeout(struct urb *urb) ...@@ -230,8 +228,7 @@ sisusb_bulk_completeout(struct urb *urb)
static int static int
sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe, void *data, sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe, void *data,
int len, int *actual_length, int timeout, unsigned int tflags, int len, int *actual_length, int timeout, unsigned int tflags)
dma_addr_t transfer_dma)
{ {
struct urb *urb = sisusb->sisurbout[index]; struct urb *urb = sisusb->sisurbout[index];
int retval, byteswritten = 0; int retval, byteswritten = 0;
...@@ -245,9 +242,6 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe, ...@@ -245,9 +242,6 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe,
urb->transfer_flags |= tflags; urb->transfer_flags |= tflags;
urb->actual_length = 0; urb->actual_length = 0;
if ((urb->transfer_dma = transfer_dma))
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
/* Set up context */ /* Set up context */
sisusb->urbout_context[index].actual_length = (timeout) ? sisusb->urbout_context[index].actual_length = (timeout) ?
NULL : actual_length; NULL : actual_length;
...@@ -297,8 +291,8 @@ sisusb_bulk_completein(struct urb *urb) ...@@ -297,8 +291,8 @@ sisusb_bulk_completein(struct urb *urb)
} }
static int static int
sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data, int len, sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data,
int *actual_length, int timeout, unsigned int tflags, dma_addr_t transfer_dma) int len, int *actual_length, int timeout, unsigned int tflags)
{ {
struct urb *urb = sisusb->sisurbin; struct urb *urb = sisusb->sisurbin;
int retval, readbytes = 0; int retval, readbytes = 0;
...@@ -311,9 +305,6 @@ sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data, ...@@ -311,9 +305,6 @@ sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data,
urb->transfer_flags |= tflags; urb->transfer_flags |= tflags;
urb->actual_length = 0; urb->actual_length = 0;
if ((urb->transfer_dma = transfer_dma))
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
sisusb->completein = 0; sisusb->completein = 0;
retval = usb_submit_urb(urb, GFP_ATOMIC); retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval == 0) { if (retval == 0) {
...@@ -422,8 +413,7 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, ...@@ -422,8 +413,7 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len,
thispass, thispass,
&transferred_len, &transferred_len,
async ? 0 : 5 * HZ, async ? 0 : 5 * HZ,
tflags, tflags);
sisusb->transfer_dma_out[index]);
if (result == -ETIMEDOUT) { if (result == -ETIMEDOUT) {
...@@ -432,29 +422,16 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, ...@@ -432,29 +422,16 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len,
return -ETIME; return -ETIME;
continue; continue;
}
} else if ((result == 0) && !async && transferred_len) { if ((result == 0) && !async && transferred_len) {
thispass -= transferred_len; thispass -= transferred_len;
if (thispass) { buffer += transferred_len;
if (sisusb->transfer_dma_out) {
/* If DMA, copy remaining
* to beginning of buffer
*/
memcpy(buffer,
buffer + transferred_len,
thispass);
} else {
/* If not DMA, simply increase
* the pointer
*/
buffer += transferred_len;
}
}
} else } else
break; break;
}; }
if (result) if (result)
return result; return result;
...@@ -530,8 +507,7 @@ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, ...@@ -530,8 +507,7 @@ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len,
thispass, thispass,
&transferred_len, &transferred_len,
5 * HZ, 5 * HZ,
tflags, tflags);
sisusb->transfer_dma_in);
if (transferred_len) if (transferred_len)
thispass = transferred_len; thispass = transferred_len;
...@@ -3132,8 +3108,7 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3132,8 +3108,7 @@ static int sisusb_probe(struct usb_interface *intf,
/* Allocate buffers */ /* Allocate buffers */
sisusb->ibufsize = SISUSB_IBUF_SIZE; sisusb->ibufsize = SISUSB_IBUF_SIZE;
if (!(sisusb->ibuf = usb_buffer_alloc(dev, SISUSB_IBUF_SIZE, if (!(sisusb->ibuf = kmalloc(SISUSB_IBUF_SIZE, GFP_KERNEL))) {
GFP_KERNEL, &sisusb->transfer_dma_in))) {
dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for input buffer"); dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for input buffer");
retval = -ENOMEM; retval = -ENOMEM;
goto error_2; goto error_2;
...@@ -3142,9 +3117,7 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3142,9 +3117,7 @@ static int sisusb_probe(struct usb_interface *intf,
sisusb->numobufs = 0; sisusb->numobufs = 0;
sisusb->obufsize = SISUSB_OBUF_SIZE; sisusb->obufsize = SISUSB_OBUF_SIZE;
for (i = 0; i < NUMOBUFS; i++) { for (i = 0; i < NUMOBUFS; i++) {
if (!(sisusb->obuf[i] = usb_buffer_alloc(dev, SISUSB_OBUF_SIZE, if (!(sisusb->obuf[i] = kmalloc(SISUSB_OBUF_SIZE, GFP_KERNEL))) {
GFP_KERNEL,
&sisusb->transfer_dma_out[i]))) {
if (i == 0) { if (i == 0) {
dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for output buffer\n"); dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for output buffer\n");
retval = -ENOMEM; retval = -ENOMEM;
......
...@@ -123,8 +123,6 @@ struct sisusb_usb_data { ...@@ -123,8 +123,6 @@ struct sisusb_usb_data {
int numobufs; /* number of obufs = number of out urbs */ int numobufs; /* number of obufs = number of out urbs */
char *obuf[NUMOBUFS], *ibuf; /* transfer buffers */ char *obuf[NUMOBUFS], *ibuf; /* transfer buffers */
int obufsize, ibufsize; int obufsize, ibufsize;
dma_addr_t transfer_dma_out[NUMOBUFS];
dma_addr_t transfer_dma_in;
struct urb *sisurbout[NUMOBUFS]; struct urb *sisurbout[NUMOBUFS];
struct urb *sisurbin; struct urb *sisurbin;
unsigned char urbstatus[NUMOBUFS]; unsigned char urbstatus[NUMOBUFS];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment