Commit 80070a40 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: storage: refactor endpoint retrieval

Use the new endpoint helpers to lookup the required bulk-in and bulk-out
endpoints and the (typically) optional interrupt-in endpoint.

Cc: usb-storage@lists.one-eyed-alien.net
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f8d8464b
...@@ -737,13 +737,11 @@ static void get_protocol(struct us_data *us) ...@@ -737,13 +737,11 @@ static void get_protocol(struct us_data *us)
/* Get the pipe settings */ /* Get the pipe settings */
static int get_pipes(struct us_data *us) static int get_pipes(struct us_data *us)
{ {
struct usb_host_interface *altsetting = struct usb_host_interface *alt = us->pusb_intf->cur_altsetting;
us->pusb_intf->cur_altsetting; struct usb_endpoint_descriptor *ep_in;
int i; struct usb_endpoint_descriptor *ep_out;
struct usb_endpoint_descriptor *ep; struct usb_endpoint_descriptor *ep_int;
struct usb_endpoint_descriptor *ep_in = NULL; int res;
struct usb_endpoint_descriptor *ep_out = NULL;
struct usb_endpoint_descriptor *ep_int = NULL;
/* /*
* Find the first endpoint of each type we need. * Find the first endpoint of each type we need.
...@@ -751,28 +749,16 @@ static int get_pipes(struct us_data *us) ...@@ -751,28 +749,16 @@ static int get_pipes(struct us_data *us)
* An optional interrupt-in 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++) { res = usb_find_common_endpoints(alt, &ep_in, &ep_out, NULL, NULL);
ep = &altsetting->endpoint[i].desc; if (res) {
usb_stor_dbg(us, "bulk endpoints not found\n");
if (usb_endpoint_xfer_bulk(ep)) { return res;
if (usb_endpoint_dir_in(ep)) {
if (!ep_in)
ep_in = ep;
} else {
if (!ep_out)
ep_out = ep;
}
}
else if (usb_endpoint_is_int_in(ep)) {
if (!ep_int)
ep_int = ep;
}
} }
if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) { res = usb_find_int_in_endpoint(alt, &ep_int);
usb_stor_dbg(us, "Endpoint sanity check failed! Rejecting dev.\n"); if (res && us->protocol == USB_PR_CBI) {
return -EIO; usb_stor_dbg(us, "interrupt endpoint not found\n");
return res;
} }
/* Calculate and store the pipe values */ /* Calculate and store the pipe values */
......
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