lantiq: clarify VG3503J name
[oweals/openwrt.git] / target / linux / mvebu / patches-4.9 / 411-net-phy-split-out-PHY-speed-and-duplex-string-genera.patch
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
4  generation
5
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.
8
9 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
10 ---
11
12 --- a/drivers/net/phy/phy.c
13 +++ b/drivers/net/phy/phy.c
14 @@ -38,26 +38,6 @@
15  
16  #include <asm/irq.h>
17  
18 -static const char *phy_speed_to_str(int speed)
19 -{
20 -       switch (speed) {
21 -       case SPEED_10:
22 -               return "10Mbps";
23 -       case SPEED_100:
24 -               return "100Mbps";
25 -       case SPEED_1000:
26 -               return "1Gbps";
27 -       case SPEED_2500:
28 -               return "2.5Gbps";
29 -       case SPEED_10000:
30 -               return "10Gbps";
31 -       case SPEED_UNKNOWN:
32 -               return "Unknown";
33 -       default:
34 -               return "Unsupported (update phy.c)";
35 -       }
36 -}
37 -
38  #define PHY_STATE_STR(_state)                  \
39         case PHY_##_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");
48         } else  {
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
52 @@ -9,6 +9,39 @@
53  #include <linux/export.h>
54  #include <linux/phy.h>
55  
56 +const char *phy_speed_to_str(int speed)
57 +{
58 +       switch (speed) {
59 +       case SPEED_10:
60 +               return "10Mbps";
61 +       case SPEED_100:
62 +               return "100Mbps";
63 +       case SPEED_1000:
64 +               return "1Gbps";
65 +       case SPEED_2500:
66 +               return "2.5Gbps";
67 +       case SPEED_10000:
68 +               return "10Gbps";
69 +       case SPEED_UNKNOWN:
70 +               return "Unknown";
71 +       default:
72 +               return "Unsupported (update phy-core.c)";
73 +       }
74 +}
75 +EXPORT_SYMBOL_GPL(phy_speed_to_str);
76 +
77 +const char *phy_duplex_to_str(unsigned int duplex)
78 +{
79 +       if (duplex == DUPLEX_HALF)
80 +               return "Half";
81 +       if (duplex == DUPLEX_FULL)
82 +               return "Full";
83 +       if (duplex == DUPLEX_UNKNOWN)
84 +               return "Unknown";
85 +       return "Unsupported (update phy-core.c)";
86 +}
87 +EXPORT_SYMBOL_GPL(phy_duplex_to_str);
88 +
89  static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad,
90                                     int addr)
91  {
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);
96  };
97  
98 +const char *phy_speed_to_str(int speed);
99 +const char *phy_duplex_to_str(unsigned int duplex);
100 +
101  /**
102   * phy_read_mmd - Convenience function for reading a register
103   * from an MMD on a given PHY.