1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Date: Mon, 2 Jan 2017 17:52:18 +0000
3 Subject: [PATCH] net: phy: split out PHY speed and duplex string
6 Other code would like to make use of this, so make the speed and duplex
7 string generation visible, and place it in a separate file.
9 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
12 --- a/drivers/net/phy/phy.c
13 +++ b/drivers/net/phy/phy.c
18 -static const char *phy_speed_to_str(int speed)
34 - return "Unsupported (update phy.c)";
38 #define PHY_STATE_STR(_state) \
40 return __stringify(_state); \
41 @@ -93,7 +73,7 @@ void phy_print_status(struct phy_device
42 netdev_info(phydev->attached_dev,
43 "Link is Up - %s/%s - flow control %s\n",
44 phy_speed_to_str(phydev->speed),
45 - DUPLEX_FULL == phydev->duplex ? "Full" : "Half",
46 + phy_duplex_to_str(phydev->duplex),
47 phydev->pause ? "rx/tx" : "off");
49 netdev_info(phydev->attached_dev, "Link is Down\n");
50 --- a/drivers/net/phy/phy-core.c
51 +++ b/drivers/net/phy/phy-core.c
53 #include <linux/export.h>
54 #include <linux/phy.h>
56 +const char *phy_speed_to_str(int speed)
72 + return "Unsupported (update phy-core.c)";
75 +EXPORT_SYMBOL_GPL(phy_speed_to_str);
77 +const char *phy_duplex_to_str(unsigned int duplex)
79 + if (duplex == DUPLEX_HALF)
81 + if (duplex == DUPLEX_FULL)
83 + if (duplex == DUPLEX_UNKNOWN)
85 + return "Unsupported (update phy-core.c)";
87 +EXPORT_SYMBOL_GPL(phy_duplex_to_str);
89 static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad,
92 --- a/include/linux/phy.h
93 +++ b/include/linux/phy.h
94 @@ -642,6 +642,9 @@ struct phy_fixup {
95 int (*run)(struct phy_device *phydev);
98 +const char *phy_speed_to_str(int speed);
99 +const char *phy_duplex_to_str(unsigned int duplex);
102 * phy_read_mmd - Convenience function for reading a register
103 * from an MMD on a given PHY.