Pass around priv, not ds. This will help with changing to an mdio
driver, and makes this driver more like mv88e6xxx.

Signed-off-by: Andrew Lunn <and...@lunn.ch>
---
 drivers/net/dsa/mv88e6060.c | 43 +++++++++++++++++++------------------
 drivers/net/dsa/mv88e6060.h |  1 +
 2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index 0b3e51f248c2..631358bf3d6b 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -18,10 +18,8 @@
 #include <net/dsa.h>
 #include "mv88e6060.h"
 
-static int reg_read(struct dsa_switch *ds, int addr, int reg)
+static int reg_read(struct mv88e6060_priv *priv, int addr, int reg)
 {
-       struct mv88e6060_priv *priv = ds->priv;
-
        return mdiobus_read_nested(priv->bus, priv->sw_addr + addr, reg);
 }
 
@@ -29,17 +27,15 @@ static int reg_read(struct dsa_switch *ds, int addr, int 
reg)
        ({                                                      \
                int __ret;                                      \
                                                                \
-               __ret = reg_read(ds, addr, reg);                \
+               __ret = reg_read(priv, addr, reg);              \
                if (__ret < 0)                                  \
                        return __ret;                           \
                __ret;                                          \
        })
 
 
-static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
+static int reg_write(struct mv88e6060_priv *priv, int addr, int reg, u16 val)
 {
-       struct mv88e6060_priv *priv = ds->priv;
-
        return mdiobus_write_nested(priv->bus, priv->sw_addr + addr, reg, val);
 }
 
@@ -47,7 +43,7 @@ static int reg_write(struct dsa_switch *ds, int addr, int 
reg, u16 val)
        ({                                                      \
                int __ret;                                      \
                                                                \
-               __ret = reg_write(ds, addr, reg, val);          \
+               __ret = reg_write(priv, addr, reg, val);                \
                if (__ret < 0)                                  \
                        return __ret;                           \
        })
@@ -97,7 +93,7 @@ static const char *mv88e6060_drv_probe(struct device *dsa_dev,
        return name;
 }
 
-static int mv88e6060_switch_reset(struct dsa_switch *ds)
+static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)
 {
        int i;
        int ret;
@@ -133,7 +129,7 @@ static int mv88e6060_switch_reset(struct dsa_switch *ds)
        return 0;
 }
 
-static int mv88e6060_setup_global(struct dsa_switch *ds)
+static int mv88e6060_setup_global(struct mv88e6060_priv *priv)
 {
        /* Disable discarding of frames with excessive collisions,
         * set the maximum frame size to 1536 bytes, and mask all
@@ -149,7 +145,7 @@ static int mv88e6060_setup_global(struct dsa_switch *ds)
        return 0;
 }
 
-static int mv88e6060_setup_port(struct dsa_switch *ds, int p)
+static int mv88e6060_setup_port(struct mv88e6060_priv *priv, int p)
 {
        int addr = REG_PORT(p);
 
@@ -159,7 +155,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int 
p)
         * port, enable Ingress and Egress Trailer tagging mode.
         */
        REG_WRITE(addr, PORT_CONTROL,
-                 dsa_is_cpu_port(ds, p) ?
+                 dsa_is_cpu_port(priv->ds, p) ?
                        PORT_CONTROL_TRAILER |
                        PORT_CONTROL_INGRESS_MODE |
                        PORT_CONTROL_STATE_FORWARDING :
@@ -172,8 +168,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) ? dsa_user_ports(ds) :
-                   BIT(dsa_to_port(ds, p)->cpu_dp->index)));
+                  (dsa_is_cpu_port(priv->ds, p) ? dsa_user_ports(priv->ds) :
+                   BIT(dsa_to_port(priv->ds, p)->cpu_dp->index)));
 
        /* Port Association Vector: when learning source addresses
         * of packets, add the address to the address database using
@@ -185,7 +181,7 @@ static int mv88e6060_setup_port(struct dsa_switch *ds, int 
p)
        return 0;
 }
 
-static int mv88e6060_setup_addr(struct dsa_switch *ds)
+static int mv88e6060_setup_addr(struct mv88e6060_priv *priv)
 {
        u8 addr[ETH_ALEN];
        u16 val;
@@ -208,25 +204,28 @@ static int mv88e6060_setup_addr(struct dsa_switch *ds)
 
 static int mv88e6060_setup(struct dsa_switch *ds)
 {
+       struct mv88e6060_priv *priv = ds->priv;
        int ret;
        int i;
 
-       ret = mv88e6060_switch_reset(ds);
+       priv->ds = ds;
+
+       ret = mv88e6060_switch_reset(priv);
        if (ret < 0)
                return ret;
 
        /* @@@ initialise atu */
 
-       ret = mv88e6060_setup_global(ds);
+       ret = mv88e6060_setup_global(priv);
        if (ret < 0)
                return ret;
 
-       ret = mv88e6060_setup_addr(ds);
+       ret = mv88e6060_setup_addr(priv);
        if (ret < 0)
                return ret;
 
        for (i = 0; i < MV88E6060_PORTS; i++) {
-               ret = mv88e6060_setup_port(ds, i);
+               ret = mv88e6060_setup_port(priv, i);
                if (ret < 0)
                        return ret;
        }
@@ -243,25 +242,27 @@ static int mv88e6060_port_to_phy_addr(int port)
 
 static int mv88e6060_phy_read(struct dsa_switch *ds, int port, int regnum)
 {
+       struct mv88e6060_priv *priv = ds->priv;
        int addr;
 
        addr = mv88e6060_port_to_phy_addr(port);
        if (addr == -1)
                return 0xffff;
 
-       return reg_read(ds, addr, regnum);
+       return reg_read(priv, addr, regnum);
 }
 
 static int
 mv88e6060_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
 {
+       struct mv88e6060_priv *priv = ds->priv;
        int addr;
 
        addr = mv88e6060_port_to_phy_addr(port);
        if (addr == -1)
                return 0xffff;
 
-       return reg_write(ds, addr, regnum, val);
+       return reg_write(priv, addr, regnum, val);
 }
 
 static const struct dsa_switch_ops mv88e6060_switch_ops = {
diff --git a/drivers/net/dsa/mv88e6060.h b/drivers/net/dsa/mv88e6060.h
index 10249bd16292..c0e7a0f2fb6a 100644
--- a/drivers/net/dsa/mv88e6060.h
+++ b/drivers/net/dsa/mv88e6060.h
@@ -117,6 +117,7 @@ struct mv88e6060_priv {
         */
        struct mii_bus *bus;
        int sw_addr;
+       struct dsa_switch *ds;
 };
 
 #endif
-- 
2.20.1

Reply via email to