]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: mv88e6xxx: factorize EEE access
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Mon, 9 May 2016 17:22:44 +0000 (13:22 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 9 May 2016 18:26:09 +0000 (14:26 -0400)
Add a MV88E6XXX_FLAG_EEE flag to describe switch models featuring Energy
Efficient Ethernet. Use it to conditionally support such access in the
common code.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6123.c
drivers/net/dsa/mv88e6131.c
drivers/net/dsa/mv88e6171.c
drivers/net/dsa/mv88e6xxx.c
drivers/net/dsa/mv88e6xxx.h

index c349fb7ec3f292ee28471bdec475988f16070104..1ad7bcd1d421d242e10f752226b960c9bafdee56 100644 (file)
@@ -117,6 +117,8 @@ struct dsa_switch_driver mv88e6123_switch_driver = {
        .set_addr               = mv88e6xxx_set_addr,
        .phy_read               = mv88e6xxx_phy_read,
        .phy_write              = mv88e6xxx_phy_write,
+       .set_eee                = mv88e6xxx_set_eee,
+       .get_eee                = mv88e6xxx_get_eee,
        .get_strings            = mv88e6xxx_get_strings,
        .get_ethtool_stats      = mv88e6xxx_get_ethtool_stats,
        .get_sset_count         = mv88e6xxx_get_sset_count,
index 1e040c6d663a1bf330984e02a36224b5efb652d7..432d3c4876915a4729b6f00198a168a6403b87d0 100644 (file)
@@ -150,6 +150,8 @@ struct dsa_switch_driver mv88e6131_switch_driver = {
        .set_addr               = mv88e6xxx_set_addr,
        .phy_read               = mv88e6xxx_phy_read,
        .phy_write              = mv88e6xxx_phy_write,
+       .set_eee                = mv88e6xxx_set_eee,
+       .get_eee                = mv88e6xxx_get_eee,
        .get_strings            = mv88e6xxx_get_strings,
        .get_ethtool_stats      = mv88e6xxx_get_ethtool_stats,
        .get_sset_count         = mv88e6xxx_get_sset_count,
index f9b20e05b895abbe3e45d2015965f36d6a3bcb81..a98e7d3c0c6421df42dbd8fba6513ce33e9911f5 100644 (file)
@@ -126,6 +126,8 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
        .set_addr               = mv88e6xxx_set_addr,
        .phy_read               = mv88e6xxx_phy_read,
        .phy_write              = mv88e6xxx_phy_write,
+       .set_eee                = mv88e6xxx_set_eee,
+       .get_eee                = mv88e6xxx_get_eee,
        .get_strings            = mv88e6xxx_get_strings,
        .get_ethtool_stats      = mv88e6xxx_get_ethtool_stats,
        .get_sset_count         = mv88e6xxx_get_sset_count,
index 4f0e047538d2e23da535a3cbdf8be45d9a880157..6aac58b8b78b5146a36ca79881b747798248edee 100644 (file)
@@ -1105,6 +1105,9 @@ int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e)
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
        int reg;
 
+       if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE))
+               return -EOPNOTSUPP;
+
        mutex_lock(&ps->smi_mutex);
 
        reg = _mv88e6xxx_phy_read_indirect(ps, port, 16);
@@ -1133,6 +1136,9 @@ int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
        int reg;
        int ret;
 
+       if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE))
+               return -EOPNOTSUPP;
+
        mutex_lock(&ps->smi_mutex);
 
        ret = _mv88e6xxx_phy_read_indirect(ps, port, 16);
index 517e95fbd10e6d3e112f307e210be91e359141ea..b99e0905992a2431233e6da32446c9f013c85220 100644 (file)
@@ -351,6 +351,10 @@ enum mv88e6xxx_family {
 };
 
 enum mv88e6xxx_cap {
+       /* Energy Efficient Ethernet.
+        */
+       MV88E6XXX_CAP_EEE,
+
        /* EEPROM Command and Data registers.
         * See GLOBAL2_EEPROM_OP and GLOBAL2_EEPROM_DATA.
         */
@@ -382,6 +386,7 @@ enum mv88e6xxx_cap {
 };
 
 /* Bitmask of capabilities */
+#define MV88E6XXX_FLAG_EEE             BIT(MV88E6XXX_CAP_EEE)
 #define MV88E6XXX_FLAG_EEPROM          BIT(MV88E6XXX_CAP_EEPROM)
 #define MV88E6XXX_FLAG_PPU             BIT(MV88E6XXX_CAP_PPU)
 #define MV88E6XXX_FLAG_SMI_PHY         BIT(MV88E6XXX_CAP_SMI_PHY)
@@ -403,7 +408,8 @@ enum mv88e6xxx_cap {
        MV88E6XXX_FLAG_PPU
 
 #define MV88E6XXX_FLAGS_FAMILY_6320    \
-       (MV88E6XXX_FLAG_EEPROM |        \
+       (MV88E6XXX_FLAG_EEE |           \
+        MV88E6XXX_FLAG_EEPROM |        \
         MV88E6XXX_FLAG_SMI_PHY |       \
         MV88E6XXX_FLAG_SWITCH_MAC |    \
         MV88E6XXX_FLAG_TEMP |          \
@@ -415,7 +421,8 @@ enum mv88e6xxx_cap {
         MV88E6XXX_FLAG_TEMP)
 
 #define MV88E6XXX_FLAGS_FAMILY_6352    \
-       (MV88E6XXX_FLAG_EEPROM |        \
+       (MV88E6XXX_FLAG_EEE |           \
+        MV88E6XXX_FLAG_EEPROM |        \
         MV88E6XXX_FLAG_SMI_PHY |       \
         MV88E6XXX_FLAG_SWITCH_MAC |    \
         MV88E6XXX_FLAG_TEMP |          \