diff options
author | Octavian Purdila <octavian.purdila@intel.com> | 2013-12-23 12:06:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-31 16:53:51 -0500 |
commit | 8d88bbffcbac2e7ceba04a9cdff97241b6b5f1db (patch) | |
tree | 4c78e69f9027583e2a4e812f18489eb8447761a3 | |
parent | 2205369a314e12fcec4781cc73ac9c08fc2b47de (diff) |
usbnet: mcs7830: rework link state detection
Even with the quirks in commit dabdaf0c (mcs7830: Fix link state
detection) there are still spurious link-down events for some chips
where the false link-down events count go over a few hundreds.
This patch takes a more conservative approach and only looks at
link-down events where the link-down state is not combined with other
states (e.g. half/full speed, pending frames in SRAM or TX status
information valid). In all other cases we assume the link is up.
Tested on MCS7830CV-DA (USB ID 9710:7830).
Cc: Ondrej Zary <linux@rainbow-software.org>
Cc: Michael Leun <lkml20120218@newton.leun.net>
Cc: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/usb/mcs7830.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c index 03832d3780aa..f54637828574 100644 --- a/drivers/net/usb/mcs7830.c +++ b/drivers/net/usb/mcs7830.c | |||
@@ -117,7 +117,6 @@ enum { | |||
117 | struct mcs7830_data { | 117 | struct mcs7830_data { |
118 | u8 multi_filter[8]; | 118 | u8 multi_filter[8]; |
119 | u8 config; | 119 | u8 config; |
120 | u8 link_counter; | ||
121 | }; | 120 | }; |
122 | 121 | ||
123 | static const char driver_name[] = "MOSCHIP usb-ethernet driver"; | 122 | static const char driver_name[] = "MOSCHIP usb-ethernet driver"; |
@@ -561,26 +560,16 @@ static void mcs7830_status(struct usbnet *dev, struct urb *urb) | |||
561 | { | 560 | { |
562 | u8 *buf = urb->transfer_buffer; | 561 | u8 *buf = urb->transfer_buffer; |
563 | bool link, link_changed; | 562 | bool link, link_changed; |
564 | struct mcs7830_data *data = mcs7830_get_data(dev); | ||
565 | 563 | ||
566 | if (urb->actual_length < 16) | 564 | if (urb->actual_length < 16) |
567 | return; | 565 | return; |
568 | 566 | ||
569 | link = !(buf[1] & 0x20); | 567 | link = !(buf[1] == 0x20); |
570 | link_changed = netif_carrier_ok(dev->net) != link; | 568 | link_changed = netif_carrier_ok(dev->net) != link; |
571 | if (link_changed) { | 569 | if (link_changed) { |
572 | data->link_counter++; | 570 | usbnet_link_change(dev, link, 0); |
573 | /* | 571 | netdev_dbg(dev->net, "Link Status is: %d\n", link); |
574 | track link state 20 times to guard against erroneous | 572 | } |
575 | link state changes reported sometimes by the chip | ||
576 | */ | ||
577 | if (data->link_counter > 20) { | ||
578 | data->link_counter = 0; | ||
579 | usbnet_link_change(dev, link, 0); | ||
580 | netdev_dbg(dev->net, "Link Status is: %d\n", link); | ||
581 | } | ||
582 | } else | ||
583 | data->link_counter = 0; | ||
584 | } | 573 | } |
585 | 574 | ||
586 | static const struct driver_info moschip_info = { | 575 | static const struct driver_info moschip_info = { |