]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/linux-3.10.y-usbnet_mcs7830_rework_link_detect.patch
ethtool: Update to 3.16
[ipfire-2.x.git] / src / patches / linux-3.10.y-usbnet_mcs7830_rework_link_detect.patch
CommitLineData
da6424d9
AF
1From 4e9792dc8ab29175295c79c35f9f6fbd2d453b35 Mon Sep 17 00:00:00 2001
2From: Octavian Purdila <octavian.purdila@intel.com>
3Date: Mon, 23 Dec 2013 19:06:31 +0200
4Subject: [PATCH] usbnet: mcs7830: rework link state detection
5
6Even with the quirks in commit dabdaf0c (mcs7830: Fix link state
7detection) there are still spurious link-down events for some chips
8where the false link-down events count go over a few hundreds.
9
10This patch takes a more conservative approach and only looks at
11link-down events where the link-down state is not combined with other
12states (e.g. half/full speed, pending frames in SRAM or TX status
13information valid). In all other cases we assume the link is up.
14
15Tested on MCS7830CV-DA (USB ID 9710:7830).
16
17Cc: Ondrej Zary <linux@rainbow-software.org>
18Cc: Michael Leun <lkml20120218@newton.leun.net>
19Cc: Ming Lei <ming.lei@canonical.com>
20Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
21Signed-off-by: David S. Miller <davem@davemloft.net>
22---
23 drivers/net/usb/mcs7830.c | 19 ++++---------------
24 1 file changed, 4 insertions(+), 15 deletions(-)
25
26diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
27index 9237c45..8dd48b5 100644
28--- a/drivers/net/usb/mcs7830.c
29+++ b/drivers/net/usb/mcs7830.c
30@@ -117,7 +117,6 @@ enum {
31 struct mcs7830_data {
32 u8 multi_filter[8];
33 u8 config;
34- u8 link_counter;
35 };
36
37 static const char driver_name[] = "MOSCHIP usb-ethernet driver";
38@@ -562,26 +561,16 @@ static void mcs7830_status(struct usbnet *dev, struct urb *urb)
39 {
40 u8 *buf = urb->transfer_buffer;
41 bool link, link_changed;
42- struct mcs7830_data *data = mcs7830_get_data(dev);
43
44 if (urb->actual_length < 16)
45 return;
46
47- link = !(buf[1] & 0x20);
48+ link = !(buf[1] == 0x20);
49 link_changed = netif_carrier_ok(dev->net) != link;
50 if (link_changed) {
51- data->link_counter++;
52- /*
53- track link state 20 times to guard against erroneous
54- link state changes reported sometimes by the chip
55- */
56- if (data->link_counter > 20) {
57- data->link_counter = 0;
58- usbnet_link_change(dev, link, 0);
59- netdev_dbg(dev->net, "Link Status is: %d\n", link);
60- }
61- } else
62- data->link_counter = 0;
63+ usbnet_link_change(dev, link, 0);
64+ netdev_dbg(dev->net, "Link Status is: %d\n", link);
65+ }
66 }
67
68 static const struct driver_info moschip_info = {
69--
702.0.0
71