Skip to content

Commit da4625a

Browse files
Russell Kingdavem330
authored andcommitted
net: phy: split out PHY speed and duplex string generation
Other code would like to make use of this, so make the speed and duplex string generation visible, and place it in a separate file. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c3ecbe7 commit da4625a

File tree

3 files changed

+53
-37
lines changed

3 files changed

+53
-37
lines changed

drivers/net/phy/phy-core.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,55 @@
99
#include <linux/export.h>
1010
#include <linux/phy.h>
1111

12+
const char *phy_speed_to_str(int speed)
13+
{
14+
switch (speed) {
15+
case SPEED_10:
16+
return "10Mbps";
17+
case SPEED_100:
18+
return "100Mbps";
19+
case SPEED_1000:
20+
return "1Gbps";
21+
case SPEED_2500:
22+
return "2.5Gbps";
23+
case SPEED_5000:
24+
return "5Gbps";
25+
case SPEED_10000:
26+
return "10Gbps";
27+
case SPEED_14000:
28+
return "14Gbps";
29+
case SPEED_20000:
30+
return "20Gbps";
31+
case SPEED_25000:
32+
return "25Gbps";
33+
case SPEED_40000:
34+
return "40Gbps";
35+
case SPEED_50000:
36+
return "50Gbps";
37+
case SPEED_56000:
38+
return "56Gbps";
39+
case SPEED_100000:
40+
return "100Gbps";
41+
case SPEED_UNKNOWN:
42+
return "Unknown";
43+
default:
44+
return "Unsupported (update phy-core.c)";
45+
}
46+
}
47+
EXPORT_SYMBOL_GPL(phy_speed_to_str);
48+
49+
const char *phy_duplex_to_str(unsigned int duplex)
50+
{
51+
if (duplex == DUPLEX_HALF)
52+
return "Half";
53+
if (duplex == DUPLEX_FULL)
54+
return "Full";
55+
if (duplex == DUPLEX_UNKNOWN)
56+
return "Unknown";
57+
return "Unsupported (update phy-core.c)";
58+
}
59+
EXPORT_SYMBOL_GPL(phy_duplex_to_str);
60+
1261
static void mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad,
1362
u16 regnum)
1463
{

drivers/net/phy/phy.c

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,6 @@
3838

3939
#include <asm/irq.h>
4040

41-
static const char *phy_speed_to_str(int speed)
42-
{
43-
switch (speed) {
44-
case SPEED_10:
45-
return "10Mbps";
46-
case SPEED_100:
47-
return "100Mbps";
48-
case SPEED_1000:
49-
return "1Gbps";
50-
case SPEED_2500:
51-
return "2.5Gbps";
52-
case SPEED_5000:
53-
return "5Gbps";
54-
case SPEED_10000:
55-
return "10Gbps";
56-
case SPEED_14000:
57-
return "14Gbps";
58-
case SPEED_20000:
59-
return "20Gbps";
60-
case SPEED_25000:
61-
return "25Gbps";
62-
case SPEED_40000:
63-
return "40Gbps";
64-
case SPEED_50000:
65-
return "50Gbps";
66-
case SPEED_56000:
67-
return "56Gbps";
68-
case SPEED_100000:
69-
return "100Gbps";
70-
case SPEED_UNKNOWN:
71-
return "Unknown";
72-
default:
73-
return "Unsupported (update phy.c)";
74-
}
75-
}
76-
7741
#define PHY_STATE_STR(_state) \
7842
case PHY_##_state: \
7943
return __stringify(_state); \
@@ -109,7 +73,7 @@ void phy_print_status(struct phy_device *phydev)
10973
netdev_info(phydev->attached_dev,
11074
"Link is Up - %s/%s - flow control %s\n",
11175
phy_speed_to_str(phydev->speed),
112-
DUPLEX_FULL == phydev->duplex ? "Full" : "Half",
76+
phy_duplex_to_str(phydev->duplex),
11377
phydev->pause ? "rx/tx" : "off");
11478
} else {
11579
netdev_info(phydev->attached_dev, "Link is Down\n");

include/linux/phy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ struct phy_fixup {
667667
int (*run)(struct phy_device *phydev);
668668
};
669669

670+
const char *phy_speed_to_str(int speed);
671+
const char *phy_duplex_to_str(unsigned int duplex);
672+
670673
/**
671674
* phy_read_mmd - Convenience function for reading a register
672675
* from an MMD on a given PHY.

0 commit comments

Comments
 (0)