Skip to content

Commit 7f65b1f

Browse files
oneukumdavem330
authored andcommitted
cdc-ether: divorce initialisation with a filter reset and a generic method
Some devices need their multicast filter reset but others are crashed by that. So the methods need to be separated. Signed-off-by: Oliver Neukum <[email protected]> Reported-by: "Ridgway, Keith" <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2f9bfd3 commit 7f65b1f

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

drivers/net/usb/cdc_ether.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,20 +310,37 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
310310
return -ENODEV;
311311
}
312312

313+
return 0;
314+
315+
bad_desc:
316+
dev_info(&dev->udev->dev, "bad CDC descriptors\n");
317+
return -ENODEV;
318+
}
319+
EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind);
320+
321+
322+
/* like usbnet_generic_cdc_bind() but handles filter initialization
323+
* correctly
324+
*/
325+
int usbnet_ether_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
326+
{
327+
int rv;
328+
329+
rv = usbnet_generic_cdc_bind(dev, intf);
330+
if (rv < 0)
331+
goto bail_out;
332+
313333
/* Some devices don't initialise properly. In particular
314334
* the packet filter is not reset. There are devices that
315335
* don't do reset all the way. So the packet filter should
316336
* be set to a sane initial value.
317337
*/
318338
usbnet_cdc_update_filter(dev);
319339

320-
return 0;
321-
322-
bad_desc:
323-
dev_info(&dev->udev->dev, "bad CDC descriptors\n");
324-
return -ENODEV;
340+
bail_out:
341+
return rv;
325342
}
326-
EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind);
343+
EXPORT_SYMBOL_GPL(usbnet_ether_cdc_bind);
327344

328345
void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
329346
{
@@ -417,7 +434,7 @@ int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
417434
BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
418435
< sizeof(struct cdc_state)));
419436

420-
status = usbnet_generic_cdc_bind(dev, intf);
437+
status = usbnet_ether_cdc_bind(dev, intf);
421438
if (status < 0)
422439
return status;
423440

include/linux/usb/usbnet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ struct cdc_state {
206206
};
207207

208208
extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *);
209+
extern int usbnet_ether_cdc_bind(struct usbnet *dev, struct usb_interface *intf);
209210
extern int usbnet_cdc_bind(struct usbnet *, struct usb_interface *);
210211
extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *);
211212
extern void usbnet_cdc_status(struct usbnet *, struct urb *);

0 commit comments

Comments
 (0)