usb-storage: use first bulk endpoints, not last
According to the Bulk-Only spec, usb-storage is supposed to use the _first_ bulk-in and bulk-out endpoints it finds, not the _last_. And while we're at it, we ought to test the direction of the interrupt endpoint as well. This patch (as842) makes both changes. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
629e4427aa
commit
1096f780d0
@@ -731,25 +731,26 @@ static int get_pipes(struct us_data *us)
|
|||||||
struct usb_endpoint_descriptor *ep_int = NULL;
|
struct usb_endpoint_descriptor *ep_int = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the endpoints we need.
|
* Find the first endpoint of each type we need.
|
||||||
* We are expecting a minimum of 2 endpoints - in and out (bulk).
|
* We are expecting a minimum of 2 endpoints - in and out (bulk).
|
||||||
* An optional interrupt is OK (necessary for CBI protocol).
|
* An optional interrupt-in is OK (necessary for CBI protocol).
|
||||||
* We will ignore any others.
|
* We will ignore any others.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
|
for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
|
||||||
ep = &altsetting->endpoint[i].desc;
|
ep = &altsetting->endpoint[i].desc;
|
||||||
|
|
||||||
/* Is it a BULK endpoint? */
|
|
||||||
if (usb_endpoint_xfer_bulk(ep)) {
|
if (usb_endpoint_xfer_bulk(ep)) {
|
||||||
/* BULK in or out? */
|
if (usb_endpoint_dir_in(ep)) {
|
||||||
if (usb_endpoint_dir_in(ep))
|
if (!ep_in)
|
||||||
ep_in = ep;
|
ep_in = ep;
|
||||||
else
|
} else {
|
||||||
|
if (!ep_out)
|
||||||
ep_out = ep;
|
ep_out = ep;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Is it an interrupt endpoint? */
|
else if (usb_endpoint_is_int_in(ep)) {
|
||||||
else if (usb_endpoint_xfer_int(ep)) {
|
if (!ep_int)
|
||||||
ep_int = ep;
|
ep_int = ep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user