Skip to content

Commit

Permalink
USB: sisusbvga: drop usb_buffer_alloc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pete Zaitcev authored and Greg Kroah-Hartman committed Sep 23, 2009
1 parent f8086a0 commit d2fb1bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 42 deletions.
53 changes: 13 additions & 40 deletions drivers/usb/misc/sisusbvga/sisusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@ sisusb_free_buffers(struct sisusb_usb_data *sisusb)

for (i = 0; i < NUMOBUFS; i++) {
if (sisusb->obuf[i]) {
usb_buffer_free(sisusb->sisusb_dev, sisusb->obufsize,
sisusb->obuf[i], sisusb->transfer_dma_out[i]);
kfree(sisusb->obuf[i]);
sisusb->obuf[i] = NULL;
}
}
if (sisusb->ibuf) {
usb_buffer_free(sisusb->sisusb_dev, sisusb->ibufsize,
sisusb->ibuf, sisusb->transfer_dma_in);
kfree(sisusb->ibuf);
sisusb->ibuf = NULL;
}
}
Expand Down Expand Up @@ -230,8 +228,7 @@ sisusb_bulk_completeout(struct urb *urb)

static int
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,
dma_addr_t transfer_dma)
int len, int *actual_length, int timeout, unsigned int tflags)
{
struct urb *urb = sisusb->sisurbout[index];
int retval, byteswritten = 0;
Expand All @@ -245,9 +242,6 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe,
urb->transfer_flags |= tflags;
urb->actual_length = 0;

if ((urb->transfer_dma = transfer_dma))
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;

/* Set up context */
sisusb->urbout_context[index].actual_length = (timeout) ?
NULL : actual_length;
Expand Down Expand Up @@ -297,8 +291,8 @@ sisusb_bulk_completein(struct urb *urb)
}

static int
sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data, int len,
int *actual_length, int timeout, unsigned int tflags, dma_addr_t transfer_dma)
sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data,
int len, int *actual_length, int timeout, unsigned int tflags)
{
struct urb *urb = sisusb->sisurbin;
int retval, readbytes = 0;
Expand All @@ -311,9 +305,6 @@ sisusb_bulkin_msg(struct sisusb_usb_data *sisusb, unsigned int pipe, void *data,
urb->transfer_flags |= tflags;
urb->actual_length = 0;

if ((urb->transfer_dma = transfer_dma))
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;

sisusb->completein = 0;
retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval == 0) {
Expand Down Expand Up @@ -422,8 +413,7 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len,
thispass,
&transferred_len,
async ? 0 : 5 * HZ,
tflags,
sisusb->transfer_dma_out[index]);
tflags);

if (result == -ETIMEDOUT) {

Expand All @@ -432,29 +422,16 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len,
return -ETIME;

continue;
}

} else if ((result == 0) && !async && transferred_len) {
if ((result == 0) && !async && transferred_len) {

thispass -= transferred_len;
if (thispass) {
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;
}
}
buffer += transferred_len;

} else
break;
};
}

if (result)
return result;
Expand Down Expand Up @@ -530,8 +507,7 @@ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len,
thispass,
&transferred_len,
5 * HZ,
tflags,
sisusb->transfer_dma_in);
tflags);

if (transferred_len)
thispass = transferred_len;
Expand Down Expand Up @@ -3132,8 +3108,7 @@ static int sisusb_probe(struct usb_interface *intf,

/* Allocate buffers */
sisusb->ibufsize = SISUSB_IBUF_SIZE;
if (!(sisusb->ibuf = usb_buffer_alloc(dev, SISUSB_IBUF_SIZE,
GFP_KERNEL, &sisusb->transfer_dma_in))) {
if (!(sisusb->ibuf = kmalloc(SISUSB_IBUF_SIZE, GFP_KERNEL))) {
dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for input buffer");
retval = -ENOMEM;
goto error_2;
Expand All @@ -3142,9 +3117,7 @@ static int sisusb_probe(struct usb_interface *intf,
sisusb->numobufs = 0;
sisusb->obufsize = SISUSB_OBUF_SIZE;
for (i = 0; i < NUMOBUFS; i++) {
if (!(sisusb->obuf[i] = usb_buffer_alloc(dev, SISUSB_OBUF_SIZE,
GFP_KERNEL,
&sisusb->transfer_dma_out[i]))) {
if (!(sisusb->obuf[i] = kmalloc(SISUSB_OBUF_SIZE, GFP_KERNEL))) {
if (i == 0) {
dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for output buffer\n");
retval = -ENOMEM;
Expand Down
2 changes: 0 additions & 2 deletions drivers/usb/misc/sisusbvga/sisusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ struct sisusb_usb_data {
int numobufs; /* number of obufs = number of out urbs */
char *obuf[NUMOBUFS], *ibuf; /* transfer buffers */
int obufsize, ibufsize;
dma_addr_t transfer_dma_out[NUMOBUFS];
dma_addr_t transfer_dma_in;
struct urb *sisurbout[NUMOBUFS];
struct urb *sisurbin;
unsigned char urbstatus[NUMOBUFS];
Expand Down

0 comments on commit d2fb1bb

Please sign in to comment.