b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan);
 
        b53_for_each_port(dev, i) {
-               if (ds->ports[i].bridge_dev != br)
+               if (dsa_to_port(ds, i)->bridge_dev != br)
                        continue;
 
                /* Add this local port to the remote port VLAN control
 
        b53_for_each_port(dev, i) {
                /* Don't touch the remaining ports */
-               if (ds->ports[i].bridge_dev != br)
+               if (dsa_to_port(ds, i)->bridge_dev != br)
                        continue;
 
                b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(i), ®);
 
        struct lan9303 *chip = ds->priv;
 
        dev_dbg(chip->dev, "%s(port %d)\n", __func__, port);
-       if (ds->ports[1].bridge_dev ==  ds->ports[2].bridge_dev) {
+       if (dsa_to_port(ds, 1)->bridge_dev == dsa_to_port(ds, 2)->bridge_dev) {
                lan9303_bridge_ports(chip);
                chip->is_bridged = true;  /* unleash stp_state_set() */
        }
 
                 * and not being setup until the port becomes enabled.
                 */
                if (ds->enabled_port_mask & BIT(i) && i != port) {
-                       if (ds->ports[i].bridge_dev != bridge)
+                       if (dsa_to_port(ds, i)->bridge_dev != bridge)
                                continue;
                        if (priv->ports[i].enable)
                                mt7530_set(priv, MT7530_PCR_P(i),
                 * is kept and not being setup until the port becomes enabled.
                 */
                if (ds->enabled_port_mask & BIT(i) && i != port) {
-                       if (ds->ports[i].bridge_dev != bridge)
+                       if (dsa_to_port(ds, i)->bridge_dev != bridge)
                                continue;
                        if (priv->ports[i].enable)
                                mt7530_clear(priv, MT7530_PCR_P(i),
 
                  ((p & 0xf) << PORT_VLAN_MAP_DBNUM_SHIFT) |
                   (dsa_is_cpu_port(ds, p) ?
                        ds->enabled_port_mask :
-                       BIT(ds->ports[p].cpu_dp->index)));
+                       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
 
        for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
                if (dsa_is_cpu_port(chip->ds, i) ||
                    dsa_is_dsa_port(chip->ds, i) ||
-                   (br && chip->ds->ports[i].bridge_dev == br))
+                   (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
                        pvlan |= BIT(i);
 
        return pvlan;
                            MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
                                continue;
 
-                       if (ds->ports[i].bridge_dev ==
+                       if (dsa_to_port(ds, i)->bridge_dev ==
                            ds->ports[port].bridge_dev)
                                break; /* same bridge, check next VLAN */
 
-                       if (!ds->ports[i].bridge_dev)
+                       if (!dsa_to_port(ds, i)->bridge_dev)
                                continue;
 
                        dev_err(ds->dev, "p%d: hw VLAN %d already used by %s\n",
                                port, vlan.vid,
-                               netdev_name(ds->ports[i].bridge_dev));
+                               netdev_name(dsa_to_port(ds, i)->bridge_dev));
                        err = -EOPNOTSUPP;
                        goto unlock;
                }
 
        int i;
 
        for (i = 1; i < QCA8K_NUM_PORTS; i++) {
-               if (ds->ports[i].bridge_dev != br)
+               if (dsa_to_port(ds, i)->bridge_dev != br)
                        continue;
                /* Add this port to the portvlan mask of the other ports
                 * in the bridge
        int i;
 
        for (i = 1; i < QCA8K_NUM_PORTS; i++) {
-               if (ds->ports[i].bridge_dev != br)
+               if (dsa_to_port(ds, i)->bridge_dev != br)
                        continue;
                /* Remove this port to the portvlan mask of the other ports
                 * in the bridge
 
        return !dsa_is_cpu_port(ds, p) && !dsa_is_dsa_port(ds, p);
 }
 
+static inline const struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
+{
+       return &ds->ports[p];
+}
+
 static inline u8 dsa_upstream_port(struct dsa_switch *ds)
 {
        struct dsa_switch_tree *dst = ds->dst;