generic: rtl8366: don't show link parameters if the link is down
authorGabor Juhos <juhosg@openwrt.org>
Sat, 26 Jun 2010 19:15:48 +0000 (19:15 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sat, 26 Jun 2010 19:15:48 +0000 (19:15 +0000)
SVN-Revision: 21908

target/linux/generic-2.6/files/drivers/net/phy/rtl8366rb.c
target/linux/generic-2.6/files/drivers/net/phy/rtl8366s.c

index 98c5a0ba85d074cfb95297836e809de87287116d..1069225d20e895ae437a4984bdc96e482d2302ba 100644 (file)
@@ -1119,19 +1119,24 @@ static int rtl8366rb_sw_get_port_link(struct switch_dev *dev,
        if (val->port_vlan % 2)
                data = data >> 8;
 
-       len = snprintf(rtl->buf, sizeof(rtl->buf),
-                       "port:%d link:%s speed:%s %s-duplex %s%s%s",
-                       val->port_vlan,
-                       (data & RTL8366S_PORT_STATUS_LINK_MASK) ? "up" : "down",
-                       rtl8366rb_speed_str(data &
+       if (data & RTL8366S_PORT_STATUS_LINK_MASK) {
+               len = snprintf(rtl->buf, sizeof(rtl->buf),
+                               "port:%d link:up speed:%s %s-duplex %s%s%s",
+                               val->port_vlan,
+                               rtl8366rb_speed_str(data &
                                          RTL8366S_PORT_STATUS_SPEED_MASK),
-                       (data & RTL8366S_PORT_STATUS_DUPLEX_MASK) ?
-                               "full" : "half",
-                       (data & RTL8366S_PORT_STATUS_TXPAUSE_MASK) ?
-                               "tx-pause ": "",
-                       (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) ?
-                               "rx-pause " : "",
-                       (data & RTL8366S_PORT_STATUS_AN_MASK) ? "nway ": "");
+                               (data & RTL8366S_PORT_STATUS_DUPLEX_MASK) ?
+                                       "full" : "half",
+                               (data & RTL8366S_PORT_STATUS_TXPAUSE_MASK) ?
+                                       "tx-pause ": "",
+                               (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) ?
+                                       "rx-pause " : "",
+                               (data & RTL8366S_PORT_STATUS_AN_MASK) ?
+                                       "nway ": "");
+       } else {
+               len = snprintf(rtl->buf, sizeof(rtl->buf), "port:%d link: down",
+                               val->port_vlan);
+       }
 
        val->value.s = rtl->buf;
        val->len = len;
index 26d5c7880b7edc79798b1207ee30a46eb19ee5ab..f30a5a3c6d87242333bcf04ac09dd779fb452605 100644 (file)
@@ -1087,19 +1087,24 @@ static int rtl8366s_sw_get_port_link(struct switch_dev *dev,
        if (val->port_vlan % 2)
                data = data >> 8;
 
-       len = snprintf(rtl->buf, sizeof(rtl->buf),
-                       "port:%d link:%s speed:%s %s-duplex %s%s%s",
-                       val->port_vlan,
-                       (data & RTL8366S_PORT_STATUS_LINK_MASK) ? "up" : "down",
-                       rtl8366s_speed_str(data &
+       if (data & RTL8366S_PORT_STATUS_LINK_MASK) {
+               len = snprintf(rtl->buf, sizeof(rtl->buf),
+                               "port:%d link:up speed:%s %s-duplex %s%s%s",
+                               val->port_vlan,
+                               rtl8366s_speed_str(data &
                                          RTL8366S_PORT_STATUS_SPEED_MASK),
-                       (data & RTL8366S_PORT_STATUS_DUPLEX_MASK) ?
-                               "full" : "half",
-                       (data & RTL8366S_PORT_STATUS_TXPAUSE_MASK) ?
-                               "tx-pause ": "",
-                       (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) ?
-                               "rx-pause " : "",
-                       (data & RTL8366S_PORT_STATUS_AN_MASK) ? "nway ": "");
+                               (data & RTL8366S_PORT_STATUS_DUPLEX_MASK) ?
+                                       "full" : "half",
+                               (data & RTL8366S_PORT_STATUS_TXPAUSE_MASK) ?
+                                       "tx-pause ": "",
+                               (data & RTL8366S_PORT_STATUS_RXPAUSE_MASK) ?
+                                       "rx-pause " : "",
+                               (data & RTL8366S_PORT_STATUS_AN_MASK) ?
+                                       "nway ": "");
+       } else {
+               len = snprintf(rtl->buf, sizeof(rtl->buf), "port:%d link: down",
+                               val->port_vlan);
+       }
 
        val->value.s = rtl->buf;
        val->len = len;