mcs7830: Implement link state detection

Add .status callback that detects link state changes.
Tested with MCS7832CV-AA chip (9710:7830, identified as rev.C by the driver).
Fixes https://bugzilla.kernel.org/show_bug.cgi?id=28532

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Ondrej Zary and committed by David S. Miller b1ff4f96 6d7407bf

Changed files
+23 -2
drivers
net
usb
+23 -2
drivers/net/usb/mcs7830.c
··· 629 629 return skb->len > 0; 630 630 } 631 631 632 + static void mcs7830_status(struct usbnet *dev, struct urb *urb) 633 + { 634 + u8 *buf = urb->transfer_buffer; 635 + bool link; 636 + 637 + if (urb->actual_length < 16) 638 + return; 639 + 640 + link = !(buf[1] & 0x20); 641 + if (netif_carrier_ok(dev->net) != link) { 642 + if (link) { 643 + netif_carrier_on(dev->net); 644 + usbnet_defer_kevent(dev, EVENT_LINK_RESET); 645 + } else 646 + netif_carrier_off(dev->net); 647 + netdev_dbg(dev->net, "Link Status is: %d\n", link); 648 + } 649 + } 650 + 632 651 static const struct driver_info moschip_info = { 633 652 .description = "MOSCHIP 7830/7832/7730 usb-NET adapter", 634 653 .bind = mcs7830_bind, 635 654 .rx_fixup = mcs7830_rx_fixup, 636 - .flags = FLAG_ETHER, 655 + .flags = FLAG_ETHER | FLAG_LINK_INTR, 656 + .status = mcs7830_status, 637 657 .in = 1, 638 658 .out = 2, 639 659 }; ··· 662 642 .description = "Sitecom LN-30 usb-NET adapter", 663 643 .bind = mcs7830_bind, 664 644 .rx_fixup = mcs7830_rx_fixup, 665 - .flags = FLAG_ETHER, 645 + .flags = FLAG_ETHER | FLAG_LINK_INTR, 646 + .status = mcs7830_status, 666 647 .in = 1, 667 648 .out = 2, 668 649 };