ar71xx: ag71xx: fix get_port_link callback
authorGabor Juhos <juhosg@openwrt.org>
Wed, 7 Mar 2012 16:32:35 +0000 (16:32 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Wed, 7 Mar 2012 16:32:35 +0000 (16:32 +0000)
SVN-Revision: 30841

target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c

index 4866aac7eaac5f177610917b2bb12afe6b53b109..8a497b0cabed4f7895cb018603674c8cd7a9725a 100644 (file)
@@ -888,9 +888,15 @@ ar7240_get_port_link(struct switch_dev *dev, int port,
                return -EINVAL;
 
        status = ar7240sw_reg_read(mii, AR7240_REG_PORT_STATUS(port));
-
-       link->link = !!(status & AR7240_PORT_STATUS_LINK_UP);
        link->aneg = !!(status & AR7240_PORT_STATUS_LINK_AUTO);
+       if (link->aneg) {
+               link->link = !!(status & AR7240_PORT_STATUS_LINK_UP);
+               if (!link->link)
+                       return 0;
+       } else {
+               link->link = true;
+       }
+
        link->duplex = !!(status & AR7240_PORT_STATUS_DUPLEX);
        link->tx_flow = !!(status & AR7240_PORT_STATUS_TXFLOW);
        link->rx_flow = !!(status & AR7240_PORT_STATUS_RXFLOW);