Skip to content

Commit f91f334

Browse files
committed
Merge branch 'usb_cdc_fixes'
Bjørn Mork says: ==================== The 2 first patches in this series are required to make the Sierra Wireless MC7710 card work in MBIM mode. They may also be required for other Qualcomm firmware based MBIM devices. Patch #1 was previously posted as a standalone patch. This version is a replacement, removing a theoretical NULL pointer exception. Patch #3 fixes a bug I introduced in v3.7 ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 8141ed9 + 6b4ef60 commit f91f334

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

drivers/net/usb/cdc_mbim.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static int cdc_mbim_resume(struct usb_interface *intf)
366366

367367
static const struct driver_info cdc_mbim_info = {
368368
.description = "CDC MBIM",
369-
.flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN,
369+
.flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN | FLAG_SEND_ZLP,
370370
.bind = cdc_mbim_bind,
371371
.unbind = cdc_mbim_unbind,
372372
.manage_power = cdc_mbim_manage_power,

drivers/net/usb/cdc_ncm.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,23 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = {
344344
.nway_reset = usbnet_nway_reset,
345345
};
346346

347+
/* return first slave interface if an IAD matches the given master */
348+
static 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+
347364
int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting)
348365
{
349366
struct cdc_ncm_ctx *ctx;
@@ -435,6 +452,16 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
435452
len -= temp;
436453
}
437454

455+
/* some buggy devices have an IAD but no CDC Union */
456+
if (!ctx->union_desc) {
457+
dev_dbg(&intf->dev, "missing CDC Union descriptor\n");
458+
ctx->data = get_iad_slave(dev->udev, intf);
459+
if (ctx->data) {
460+
ctx->control = intf;
461+
dev_dbg(&intf->dev, "got slave from IAD\n");
462+
}
463+
}
464+
438465
/* check if we got everything */
439466
if ((ctx->control == NULL) || (ctx->data == NULL) ||
440467
((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf))))
@@ -497,7 +524,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
497524
error2:
498525
usb_set_intfdata(ctx->control, NULL);
499526
usb_set_intfdata(ctx->data, NULL);
500-
usb_driver_release_interface(driver, ctx->data);
527+
if (ctx->data != ctx->control)
528+
usb_driver_release_interface(driver, ctx->data);
501529
error:
502530
cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]);
503531
dev->data[0] = 0;

0 commit comments

Comments
 (0)