Commit b2d03eb5 authored by Hans de Goede's avatar Hans de Goede Committed by Sarah Sharp

usbfs: proc_do_submiturb use a local variable for number_of_packets

This is a preparation patch for adding support for bulk streams.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
parent 5ec9c177
...@@ -1208,6 +1208,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1208,6 +1208,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
struct usb_ctrlrequest *dr = NULL; struct usb_ctrlrequest *dr = NULL;
unsigned int u, totlen, isofrmlen; unsigned int u, totlen, isofrmlen;
int i, ret, is_in, num_sgs = 0, ifnum = -1; int i, ret, is_in, num_sgs = 0, ifnum = -1;
int number_of_packets = 0;
void *buf; void *buf;
if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP | if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP |
...@@ -1261,7 +1262,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1261,7 +1262,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
le16_to_cpup(&dr->wIndex)); le16_to_cpup(&dr->wIndex));
if (ret) if (ret)
goto error; goto error;
uurb->number_of_packets = 0;
uurb->buffer_length = le16_to_cpup(&dr->wLength); uurb->buffer_length = le16_to_cpup(&dr->wLength);
uurb->buffer += 8; uurb->buffer += 8;
if ((dr->bRequestType & USB_DIR_IN) && uurb->buffer_length) { if ((dr->bRequestType & USB_DIR_IN) && uurb->buffer_length) {
...@@ -1291,7 +1291,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1291,7 +1291,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
uurb->type = USBDEVFS_URB_TYPE_INTERRUPT; uurb->type = USBDEVFS_URB_TYPE_INTERRUPT;
goto interrupt_urb; goto interrupt_urb;
} }
uurb->number_of_packets = 0;
num_sgs = DIV_ROUND_UP(uurb->buffer_length, USB_SG_SIZE); num_sgs = DIV_ROUND_UP(uurb->buffer_length, USB_SG_SIZE);
if (num_sgs == 1 || num_sgs > ps->dev->bus->sg_tablesize) if (num_sgs == 1 || num_sgs > ps->dev->bus->sg_tablesize)
num_sgs = 0; num_sgs = 0;
...@@ -1301,7 +1300,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1301,7 +1300,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
if (!usb_endpoint_xfer_int(&ep->desc)) if (!usb_endpoint_xfer_int(&ep->desc))
return -EINVAL; return -EINVAL;
interrupt_urb: interrupt_urb:
uurb->number_of_packets = 0;
break; break;
case USBDEVFS_URB_TYPE_ISO: case USBDEVFS_URB_TYPE_ISO:
...@@ -1311,15 +1309,16 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1311,15 +1309,16 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
return -EINVAL; return -EINVAL;
if (!usb_endpoint_xfer_isoc(&ep->desc)) if (!usb_endpoint_xfer_isoc(&ep->desc))
return -EINVAL; return -EINVAL;
number_of_packets = uurb->number_of_packets;
isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) *
uurb->number_of_packets; number_of_packets;
if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL))) if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) {
ret = -EFAULT; ret = -EFAULT;
goto error; goto error;
} }
for (totlen = u = 0; u < uurb->number_of_packets; u++) { for (totlen = u = 0; u < number_of_packets; u++) {
/* /*
* arbitrary limit need for USB 3.0 * arbitrary limit need for USB 3.0
* bMaxBurst (0~15 allowed, 1~16 packets) * bMaxBurst (0~15 allowed, 1~16 packets)
...@@ -1350,7 +1349,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1350,7 +1349,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
ret = -EFAULT; ret = -EFAULT;
goto error; goto error;
} }
as = alloc_async(uurb->number_of_packets); as = alloc_async(number_of_packets);
if (!as) { if (!as) {
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto error;
...@@ -1444,7 +1443,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1444,7 +1443,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
as->urb->setup_packet = (unsigned char *)dr; as->urb->setup_packet = (unsigned char *)dr;
dr = NULL; dr = NULL;
as->urb->start_frame = uurb->start_frame; as->urb->start_frame = uurb->start_frame;
as->urb->number_of_packets = uurb->number_of_packets; as->urb->number_of_packets = number_of_packets;
if (uurb->type == USBDEVFS_URB_TYPE_ISO || if (uurb->type == USBDEVFS_URB_TYPE_ISO ||
ps->dev->speed == USB_SPEED_HIGH) ps->dev->speed == USB_SPEED_HIGH)
as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); as->urb->interval = 1 << min(15, ep->desc.bInterval - 1);
...@@ -1452,7 +1451,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, ...@@ -1452,7 +1451,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
as->urb->interval = ep->desc.bInterval; as->urb->interval = ep->desc.bInterval;
as->urb->context = as; as->urb->context = as;
as->urb->complete = async_completed; as->urb->complete = async_completed;
for (totlen = u = 0; u < uurb->number_of_packets; u++) { for (totlen = u = 0; u < number_of_packets; u++) {
as->urb->iso_frame_desc[u].offset = totlen; as->urb->iso_frame_desc[u].offset = totlen;
as->urb->iso_frame_desc[u].length = isopkt[u].length; as->urb->iso_frame_desc[u].length = isopkt[u].length;
totlen += isopkt[u].length; totlen += isopkt[u].length;
......
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