aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-10-09 11:19:29 -0400
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2014-03-04 18:38:04 -0500
commit948cd8c18c466fdcbe707bb2a42a148796bfccdd (patch)
treeaa01759923cee68262cc5ed40340576afbc436e3 /drivers/usb/core
parentb2d03eb56e66620a9b27f1a0c2795722087effc9 (diff)
usbfs: Add support for bulk stream ids
This patch makes it possible to specify a bulk stream id when submitting an urb using the async usbfs API. It overloads the number_of_packets usbdevfs_urb field for this. This is not pretty, but given other constraints it is the best we can do. The reasoning leading to this goes as follows: 1) We want to support bulk streams in the usbfs API 2) We do not want to extend the usbdevfs_urb struct with a new member, as that would mean defining new ioctl numbers for all async API ioctls + adding compat versions for the old ones (times 2 for 32 bit support) 3) 1 + 2 means we need to re-use an existing field 4) number_of_packets is only used for isoc urbs, and streams are bulk only so it is the best (and only) candidate for re-using Note that: 1) This patch only uses number_of_packets as stream_id if the app has actually allocated streams on the ep, so that old apps which may have garbage in there (as it was unused until now in the bulk case), will not break 2) This patch does not add support for allocating / freeing bulk-streams, that is done in a follow up patch Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/devio.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index c88d8bfaca8d..d7571a63181d 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1209,6 +1209,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1209 unsigned int u, totlen, isofrmlen; 1209 unsigned int u, totlen, isofrmlen;
1210 int i, ret, is_in, num_sgs = 0, ifnum = -1; 1210 int i, ret, is_in, num_sgs = 0, ifnum = -1;
1211 int number_of_packets = 0; 1211 int number_of_packets = 0;
1212 unsigned int stream_id = 0;
1212 void *buf; 1213 void *buf;
1213 1214
1214 if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP | 1215 if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP |
@@ -1294,6 +1295,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1294 num_sgs = DIV_ROUND_UP(uurb->buffer_length, USB_SG_SIZE); 1295 num_sgs = DIV_ROUND_UP(uurb->buffer_length, USB_SG_SIZE);
1295 if (num_sgs == 1 || num_sgs > ps->dev->bus->sg_tablesize) 1296 if (num_sgs == 1 || num_sgs > ps->dev->bus->sg_tablesize)
1296 num_sgs = 0; 1297 num_sgs = 0;
1298 if (ep->streams)
1299 stream_id = uurb->stream_id;
1297 break; 1300 break;
1298 1301
1299 case USBDEVFS_URB_TYPE_INTERRUPT: 1302 case USBDEVFS_URB_TYPE_INTERRUPT:
@@ -1444,6 +1447,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1444 dr = NULL; 1447 dr = NULL;
1445 as->urb->start_frame = uurb->start_frame; 1448 as->urb->start_frame = uurb->start_frame;
1446 as->urb->number_of_packets = number_of_packets; 1449 as->urb->number_of_packets = number_of_packets;
1450 as->urb->stream_id = stream_id;
1447 if (uurb->type == USBDEVFS_URB_TYPE_ISO || 1451 if (uurb->type == USBDEVFS_URB_TYPE_ISO ||
1448 ps->dev->speed == USB_SPEED_HIGH) 1452 ps->dev->speed == USB_SPEED_HIGH)
1449 as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); 1453 as->urb->interval = 1 << min(15, ep->desc.bInterval - 1);