summaryrefslogtreecommitdiff
path: root/drivers/usb/class
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-03-17 13:35:48 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-23 15:54:08 +0300
commitf8d8464bfc90e058fe68dee02121d46f661f68cd (patch)
treea0c2e9ec0825f21c798ebbe2c7138c73014ec55e /drivers/usb/class
parentaf59f8955fc572b2a0b61dedfbcd681265a19fde (diff)
downloadlinux-f8d8464bfc90e058fe68dee02121d46f661f68cd.tar.xz
USB: cdc-acm: refactor endpoint retrieval
Use the new endpoint helpers to lookup the required bulk-in, bulk-out and interrupt-in endpoints for collapsed interfaces. Note that there is already a check verifying that there are exactly three endpoints so we'd still be bailing out if there's an unexpected endpoint type. Cc: Oliver Neukum <oneukum@suse.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/class')
-rw-r--r--drivers/usb/class/cdc-acm.c24
1 files changed, 7 insertions, 17 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: