Fix: qmi_wwan_m.c

This commit is contained in:
sfwtw 2025-03-05 15:45:51 +08:00
parent df6b3e3b1e
commit 50a68f594a

View File

@ -231,8 +231,13 @@ static int qmi_wwan_register_subdriver(struct usbnet *dev)
atomic_set(&info->pmcount, 0); atomic_set(&info->pmcount, 0);
/* register subdriver */ /* register subdriver */
#if (LINUX_VERSION_CODE > KERNEL_VERSION( 5,12,0 ))
subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc,
4096, WWAN_PORT_QMI, &qmi_wwan_cdc_wdm_manage_power);
#else
subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc,
4096, &qmi_wwan_cdc_wdm_manage_power); 4096, &qmi_wwan_cdc_wdm_manage_power);
#endif
if (IS_ERR(subdriver)) { if (IS_ERR(subdriver)) {
dev_err(&info->control->dev, "subdriver registration failed\n"); dev_err(&info->control->dev, "subdriver registration failed\n");
rv = PTR_ERR(subdriver); rv = PTR_ERR(subdriver);
@ -267,7 +272,7 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
/* set up initial state */ /* set up initial state */
info->control = intf; info->control = intf;
info->data = intf; info->data = intf;
/*add by zhangqingyun@meigsmart.com begain /* add by zhangqingyun@meigsmart.com begain */
/* and a number of CDC descriptors */ /* and a number of CDC descriptors */
while (len > 3) { while (len > 3) {
struct usb_descriptor_header *h = (void *)buf; struct usb_descriptor_header *h = (void *)buf;
@ -368,8 +373,16 @@ next_desc:
/* make MAC addr easily distinguishable from an IP header */ /* make MAC addr easily distinguishable from an IP header */
if (possibly_iphdr(dev->net->dev_addr)) { if (possibly_iphdr(dev->net->dev_addr)) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)
dev->net->dev_addr[0] |= 0x02; /* set local assignment bit */ dev->net->dev_addr[0] |= 0x02; /* set local assignment bit */
dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */ dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */
#else
u8 addr = dev->net->dev_addr[0];
addr |= 0x02; /* set local assignment bit */
addr &= 0xbf; /* clear "IP" bit */
dev_addr_mod(dev->net, 0, &addr, 1);
#endif
} }
dev->net->netdev_ops = &qmi_wwan_netdev_ops; dev->net->netdev_ops = &qmi_wwan_netdev_ops;