usbnet: introduce usbnet_link_change API
authorMing Lei <ming.lei@canonical.com>
Thu, 11 Apr 2013 04:40:30 +0000 (04:40 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Apr 2013 19:57:16 +0000 (15:57 -0400)
This patch introduces the API of usbnet_link_change, so that
usbnet can handle link change centrally, which may help to
implement killing traffic URBs for saving USB bus bandwidth
and host controller power.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/usbnet.c
include/linux/usb/usbnet.h

index 51f3192f3931e0a179dcb619e4e714a0565656fc..40e4237b0a3a13e29df690e9ef6fd02e7e220894 100644 (file)
@@ -1653,6 +1653,19 @@ int usbnet_manage_power(struct usbnet *dev, int on)
 }
 EXPORT_SYMBOL(usbnet_manage_power);
 
+void usbnet_link_change(struct usbnet *dev, bool link, bool need_reset)
+{
+       /* update link after link is reseted */
+       if (link && !need_reset)
+               netif_carrier_on(dev->net);
+       else
+               netif_carrier_off(dev->net);
+
+       if (need_reset && link)
+               usbnet_defer_kevent(dev, EVENT_LINK_RESET);
+}
+EXPORT_SYMBOL(usbnet_link_change);
+
 /*-------------------------------------------------------------------------*/
 static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
                             u16 value, u16 index, void *data, u16 size)
index 0e5ac93bab101bea0526ee3b54f52ed3b0f72099..eb021b8f53bd720b4e3f30fabf690e8fd70cba40 100644 (file)
@@ -245,5 +245,6 @@ extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
 extern int usbnet_nway_reset(struct net_device *net);
 
 extern int usbnet_manage_power(struct usbnet *, int);
+extern void usbnet_link_change(struct usbnet *, bool, bool);
 
 #endif /* __LINUX_USB_USBNET_H */