[PATCH experimental 2/6] usb: cdc-wdm: prepare endpoint detection for interfaces with > 1 endpoint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Search for the first interrupt endpoint and use that regardless of what
other endpoints might be present on the interface

Signed-off-by: Bjørn Mork <bjorn@xxxxxxx>
---
 drivers/usb/class/cdc-wdm.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index e81565f..1e28100 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -617,10 +617,12 @@ static void wdm_rxwork(struct work_struct *work)
 
 /* --- hotplug --- */
 
-static struct wdm_device *wdm_create(struct usb_interface *intf, struct usb_endpoint_descriptor *ep, u16 bufsize)
+static struct wdm_device *wdm_create(struct usb_interface *intf, u16 bufsize)
 {
-	int rv = -ENOMEM;
+	int i, rv = -ENOMEM;
 	struct wdm_device *desc;
+	struct usb_host_interface *iface;
+	struct usb_endpoint_descriptor *ep = NULL;
 
 	desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
 	if (!desc)
@@ -636,7 +638,13 @@ static struct wdm_device *wdm_create(struct usb_interface *intf, struct usb_endp
 	INIT_WORK(&desc->rxwork, wdm_rxwork);
 
 	rv = -EINVAL;
-	if (!ep || !usb_endpoint_is_int_in(ep))
+	iface = intf->cur_altsetting;
+	for (i = 0; i < iface->desc.bNumEndpoints; i++) {
+		ep = &iface->endpoint[i].desc;
+		if (ep && usb_endpoint_is_int_in(ep))
+			break;
+	}
+	if (!ep)
 		goto err;
 
 	desc->wMaxPacketSize = usb_endpoint_maxp(ep);
@@ -713,8 +721,6 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
 	int rv = -EINVAL;
 	struct wdm_device *desc;
-	struct usb_host_interface *iface;
-	struct usb_endpoint_descriptor *ep;
 	struct usb_cdc_dmm_desc *dmhd;
 	u8 *buffer = intf->altsetting->extra;
 	int buflen = intf->altsetting->extralen;
@@ -749,12 +755,10 @@ next_desc:
 		buffer += buffer[0];
 	}
 
-	iface = intf->cur_altsetting;
-	if (iface->desc.bNumEndpoints != 1)
+	if (intf->cur_altsetting->desc.bNumEndpoints != 1)
 		goto err;
-	ep = &iface->endpoint[0].desc;
 
-	desc = wdm_create(intf, ep, maxcom);
+	desc = wdm_create(intf, maxcom);
 	if (IS_ERR(desc)) {
 		rv = PTR_ERR(desc);
 		goto err;
-- 
1.7.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux