net: phy: display human readable PHY speed settings
authorFlorian Fainelli <f.fainelli@gmail.com>
Wed, 12 Feb 2014 01:27:35 +0000 (17:27 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Feb 2014 00:08:19 +0000 (19:08 -0500)
Use a convenience function: phy_speed_to_str() which will display human
readable speeds.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy.c

index 8ae22603b1b188ad2a3cc334aa716d155f1a30eb..36fc6e16b56986d9a99a56e7c2c459f1b65d9985 100644 (file)
 
 #include <asm/irq.h>
 
+static const char *phy_speed_to_str(int speed)
+{
+       switch (speed) {
+       case SPEED_10:
+               return "10Mbps";
+       case SPEED_100:
+               return "100Mbps";
+       case SPEED_1000:
+               return "1Gbps";
+       case SPEED_2500:
+               return "2.5Gbps";
+       case SPEED_10000:
+               return "10Gbps";
+       case SPEED_UNKNOWN:
+               return "Unknown";
+       default:
+               return "Unsupported (update phy.c)";
+       }
+}
+
 /**
  * phy_print_status - Convenience function to print out the current phy status
  * @phydev: the phy_device struct
@@ -46,8 +66,8 @@ void phy_print_status(struct phy_device *phydev)
 {
        if (phydev->link) {
                netdev_info(phydev->attached_dev,
-                       "Link is Up - %d/%s - flow control %s\n",
-                       phydev->speed,
+                       "Link is Up - %s/%s - flow control %s\n",
+                       phy_speed_to_str(phydev->speed),
                        DUPLEX_FULL == phydev->duplex ? "Full" : "Half",
                        phydev->pause ? "rx/tx" : "off");
        } else  {