summaryrefslogtreecommitdiff
path: root/drivers/usb/class
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/class')
-rw-r--r--drivers/usb/class/cdc-acm.c24
-rw-r--r--drivers/usb/class/usblp.c35
2 files changed, 20 insertions, 39 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index d5388938bc7a..00d55ba8983f 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1174,6 +1174,7 @@ static int acm_probe(struct usb_interface *intf,
int combined_interfaces = 0;
struct device *tty_dev;
int rv = -ENOMEM;
+ int res;
/* normal quirks */
quirks = (unsigned long)id->driver_info;
@@ -1274,23 +1275,12 @@ static int acm_probe(struct usb_interface *intf,
return -EINVAL;
}
look_for_collapsed_interface:
- for (i = 0; i < 3; i++) {
- struct usb_endpoint_descriptor *ep;
- ep = &data_interface->cur_altsetting->endpoint[i].desc;
-
- if (usb_endpoint_is_int_in(ep))
- epctrl = ep;
- else if (usb_endpoint_is_bulk_out(ep))
- epwrite = ep;
- else if (usb_endpoint_is_bulk_in(ep))
- epread = ep;
- else
- return -EINVAL;
- }
- if (!epctrl || !epread || !epwrite)
- return -ENODEV;
- else
- goto made_compressed_probe;
+ res = usb_find_common_endpoints(data_interface->cur_altsetting,
+ &epread, &epwrite, &epctrl, NULL);
+ if (res)
+ return res;
+
+ goto made_compressed_probe;
}
skip_normal_probe:
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index cc61055fb9be..73bd9a2ac530 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1239,8 +1239,9 @@ static int usblp_select_alts(struct usblp *usblp)
{
struct usb_interface *if_alt;
struct usb_host_interface *ifd;
- struct usb_endpoint_descriptor *epd, *epwrite, *epread;
- int p, i, e;
+ struct usb_endpoint_descriptor *epwrite, *epread;
+ int p, i;
+ int res;
if_alt = usblp->intf;
@@ -1260,31 +1261,21 @@ static int usblp_select_alts(struct usblp *usblp)
ifd->desc.bInterfaceProtocol > USBLP_LAST_PROTOCOL)
continue;
- /* Look for bulk OUT and IN endpoints. */
- epwrite = epread = NULL;
- for (e = 0; e < ifd->desc.bNumEndpoints; e++) {
- epd = &ifd->endpoint[e].desc;
-
- if (usb_endpoint_is_bulk_out(epd))
- if (!epwrite)
- epwrite = epd;
-
- if (usb_endpoint_is_bulk_in(epd))
- if (!epread)
- epread = epd;
+ /* Look for the expected bulk endpoints. */
+ if (ifd->desc.bInterfaceProtocol > 1) {
+ res = usb_find_common_endpoints(ifd,
+ &epread, &epwrite, NULL, NULL);
+ } else {
+ epread = NULL;
+ res = usb_find_bulk_out_endpoint(ifd, &epwrite);
}
/* Ignore buggy hardware without the right endpoints. */
- if (!epwrite || (ifd->desc.bInterfaceProtocol > 1 && !epread))
+ if (res)
continue;
- /*
- * Turn off reads for USB_CLASS_PRINTER/1/1 (unidirectional)
- * interfaces and buggy bidirectional printers.
- */
- if (ifd->desc.bInterfaceProtocol == 1) {
- epread = NULL;
- } else if (usblp->quirks & USBLP_QUIRK_BIDIR) {
+ /* Turn off reads for buggy bidirectional printers. */
+ if (usblp->quirks & USBLP_QUIRK_BIDIR) {
printk(KERN_INFO "usblp%d: Disabling reads from "
"problematic bidirectional printer\n",
usblp->minor);