aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2013-01-25 18:36:59 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-27 19:27:39 -0500
commit56a666dcfcb46e998a1bd969fb201bf51de3c412 (patch)
tree31d4a677a641d633408ac5068b0c6c1100341576 /drivers/net/usb
parent2afd0a24da6c63ad3c1af1c510cb91c7befdc8d0 (diff)
net: cdc_ncm: use IAD provided by the USB core
commit 9992c2e (net: cdc_ncm: workaround for missing CDC Union) added code to lookup an IAD for the interface we are probing. This is redundant. The USB core has already done the lookup and saved the result in the USB interface struct. Use that instead. Cc: Greg Suarez <gsuarez@smithmicro.com> Cc: Alexey Orishko <alexey.orishko@stericsson.com> Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/cdc_ncm.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index f94711caa08a..9197b2c72ca3 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -344,23 +344,6 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = {
344 .nway_reset = usbnet_nway_reset, 344 .nway_reset = usbnet_nway_reset,
345}; 345};
346 346
347/* return first slave interface if an IAD matches the given master */
348static struct usb_interface *get_iad_slave(struct usb_device *udev,
349 struct usb_interface *master) {
350 int i;
351 struct usb_interface_assoc_descriptor *iad;
352 u8 mnum = master->cur_altsetting->desc.bInterfaceNumber;
353
354 for (i = 0; i < USB_MAXIADS; i++) {
355 iad = udev->actconfig->intf_assoc[i];
356 if (!iad)
357 break;
358 if (iad->bFirstInterface == mnum && iad->bInterfaceCount == 2)
359 return usb_ifnum_to_if(udev, mnum + 1);
360 }
361 return NULL;
362}
363
364int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting) 347int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting)
365{ 348{
366 struct cdc_ncm_ctx *ctx; 349 struct cdc_ncm_ctx *ctx;
@@ -453,13 +436,10 @@ advance:
453 } 436 }
454 437
455 /* some buggy devices have an IAD but no CDC Union */ 438 /* some buggy devices have an IAD but no CDC Union */
456 if (!ctx->union_desc) { 439 if (!ctx->union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) {
457 dev_dbg(&intf->dev, "missing CDC Union descriptor\n"); 440 ctx->control = intf;
458 ctx->data = get_iad_slave(dev->udev, intf); 441 ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1);
459 if (ctx->data) { 442 dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD\n");
460 ctx->control = intf;
461 dev_dbg(&intf->dev, "got slave from IAD\n");
462 }
463 } 443 }
464 444
465 /* check if we got everything */ 445 /* check if we got everything */