net: dsa: mv88e6xxx: factorize switch setup
[cascardo/linux.git] / drivers / net / dsa / mv88e6171.c
index 4bbf2e1..4bf517a 100644 (file)
@@ -58,63 +58,10 @@ static const char *mv88e6171_drv_probe(struct device *dsa_dev,
                                   ARRAY_SIZE(mv88e6171_table));
 }
 
-static int mv88e6171_setup_global(struct dsa_switch *ds)
-{
-       struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-       u32 upstream_port = dsa_upstream_port(ds);
-       int ret;
-       u32 reg;
-
-       /* Discard packets with excessive collisions, mask all
-        * interrupt sources, enable PPU.
-        */
-       ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL,
-                                 GLOBAL_CONTROL_PPU_ENABLE |
-                                 GLOBAL_CONTROL_DISCARD_EXCESS);
-       if (ret)
-               return ret;
-
-       /* Configure the upstream port, and configure the upstream
-        * port as the port to which ingress and egress monitor frames
-        * are to be sent.
-        */
-       reg = upstream_port << GLOBAL_MONITOR_CONTROL_INGRESS_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_EGRESS_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_ARP_SHIFT |
-               upstream_port << GLOBAL_MONITOR_CONTROL_MIRROR_SHIFT;
-       ret = mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_MONITOR_CONTROL, reg);
-       if (ret)
-               return ret;
-
-       /* Disable remote management for now, and set the switch's
-        * DSA device number.
-        */
-       return mv88e6xxx_reg_write(ps, REG_GLOBAL, GLOBAL_CONTROL_2,
-                                  ds->index & 0x1f);
-}
-
-static int mv88e6171_setup(struct dsa_switch *ds)
-{
-       struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-       int ret;
-
-       ps->ds = ds;
-
-       ret = mv88e6xxx_setup_common(ps);
-       if (ret < 0)
-               return ret;
-
-       ret = mv88e6171_setup_global(ds);
-       if (ret < 0)
-               return ret;
-
-       return mv88e6xxx_setup_ports(ds);
-}
-
 struct dsa_switch_driver mv88e6171_switch_driver = {
        .tag_protocol           = DSA_TAG_PROTO_EDSA,
        .probe                  = mv88e6171_drv_probe,
-       .setup                  = mv88e6171_setup,
+       .setup                  = mv88e6xxx_setup,
        .set_addr               = mv88e6xxx_set_addr,
        .phy_read               = mv88e6xxx_phy_read,
        .phy_write              = mv88e6xxx_phy_write,