]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
net: dsa: introduce dsa_user_ports helper
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Thu, 26 Oct 2017 15:22:56 +0000 (11:22 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Oct 2017 15:00:09 +0000 (00:00 +0900)
Introduce a dsa_user_ports() helper to return the ds->enabled_port_mask
mask which is more explicit. This will also minimize diffs when touching
this internal mask.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mt7530.c
drivers/net/dsa/mv88e6060.c
drivers/net/dsa/qca8k.c
include/net/dsa.h
net/dsa/dsa2.c
net/dsa/legacy.c

index d1d4eea6a875894dfc9f2aa4e5ebc36690d82eaf..627c039f12ca71de7ce7b79662ad6b14a340ab35 100644 (file)
@@ -688,7 +688,7 @@ mt7530_cpu_port_enable(struct mt7530_priv *priv,
         * the switch
         */
        mt7530_write(priv, MT7530_PCR_P(port),
-                    PCR_MATRIX(priv->ds->enabled_port_mask));
+                    PCR_MATRIX(dsa_user_ports(priv->ds)));
 
        return 0;
 }
index f78b9e13be1cb649130eb3ba28183ae187695061..45768e3c5bc587a1ce6b755e01ad2c2d5b5169ce 100644 (file)
@@ -175,9 +175,8 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int p)
         */
        REG_WRITE(addr, PORT_VLAN_MAP,
                  ((p & 0xf) << PORT_VLAN_MAP_DBNUM_SHIFT) |
-                  (dsa_is_cpu_port(ds, p) ?
-                       ds->enabled_port_mask :
-                       BIT(dsa_to_port(ds, p)->cpu_dp->index)));
+                  (dsa_is_cpu_port(ds, p) ? dsa_user_ports(ds) :
+                   BIT(dsa_to_port(ds, p)->cpu_dp->index)));
 
        /* Port Association Vector: when learning source addresses
         * of packets, add the address to the address database using
index 37125858fe80de3aee68d4890e7b4d7ebacfbeb9..cf72e274275fe926f45ee77aa2ab853851964ef5 100644 (file)
@@ -551,8 +551,7 @@ qca8k_setup(struct dsa_switch *ds)
                /* CPU port gets connected to all user ports of the switch */
                if (dsa_is_cpu_port(ds, i)) {
                        qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(QCA8K_CPU_PORT),
-                                 QCA8K_PORT_LOOKUP_MEMBER,
-                                 ds->enabled_port_mask);
+                                 QCA8K_PORT_LOOKUP_MEMBER, dsa_user_ports(ds));
                }
 
                /* Invividual user ports get connected to CPU port only */
index 49701d958663f64f52a524dae9b34c98384f6654..dc772806239671f90bad4a06d3e2a7491e87a5ab 100644 (file)
@@ -276,6 +276,11 @@ static inline bool dsa_is_user_port(struct dsa_switch *ds, int p)
        return !!(ds->enabled_port_mask & BIT(p));
 }
 
+static inline u32 dsa_user_ports(struct dsa_switch *ds)
+{
+       return ds->enabled_port_mask;
+}
+
 static inline const struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
 {
        return &ds->ports[p];
index 62485a57dbfc9eb967fa0eb67767579ee621b065..d43c59c91058c84933f1811884c44e14cd1a3d73 100644 (file)
@@ -312,7 +312,7 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
         * the slave MDIO bus driver rely on these values for probing PHY
         * devices or not
         */
-       ds->phys_mii_mask = ds->enabled_port_mask;
+       ds->phys_mii_mask |= dsa_user_ports(ds);
 
        /* Add the switch to devlink before calling setup, so that setup can
         * add dpipe tables
index 0b79c6171d0d3ffa4c86556fd692b5af7f849d77..fa543c4a6061146cb2c7b8f210801c38a5cfa55b 100644 (file)
@@ -136,7 +136,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
        /* Make the built-in MII bus mask match the number of ports,
         * switch drivers can override this later
         */
-       ds->phys_mii_mask = ds->enabled_port_mask;
+       ds->phys_mii_mask |= dsa_user_ports(ds);
 
        /*
         * If the CPU connects to this switch, set the switch tree