aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa/mv88e6352.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2015-04-02 04:06:33 +0200
committerDavid S. Miller <davem@davemloft.net>2015-04-01 22:55:40 -0400
commit44e50ddbc74a4bd6a862be9e6de22bce8c0b4150 (patch)
tree924eef387293c87024a27716e711c5649c211ed9 /drivers/net/dsa/mv88e6352.c
parentnet: dsa: mv88e6123_61_65: Determine and use number of switch ports (diff)
downloadlinux-dev-44e50ddbc74a4bd6a862be9e6de22bce8c0b4150.tar.xz
linux-dev-44e50ddbc74a4bd6a862be9e6de22bce8c0b4150.zip
net: dsa: Consistently set and use ps->num_ports
As a step towards consolidating code, consistently set the number of ports in the private state structure, and make use of it in loops. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--drivers/net/dsa/mv88e6352.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c
index 41fe3a6a72d1..040027fcd013 100644
--- a/drivers/net/dsa/mv88e6352.c
+++ b/drivers/net/dsa/mv88e6352.c
@@ -47,12 +47,13 @@ static char *mv88e6352_probe(struct device *host_dev, int sw_addr)
static int mv88e6352_switch_reset(struct dsa_switch *ds)
{
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
unsigned long timeout;
int ret;
int i;
/* Set all ports to the disabled state. */
- for (i = 0; i < 7; i++) {
+ for (i = 0; i < ps->num_ports; i++) {
ret = REG_READ(REG_PORT(i), 0x04);
REG_WRITE(REG_PORT(i), 0x04, ret & 0xfffc);
}
@@ -82,6 +83,7 @@ static int mv88e6352_switch_reset(struct dsa_switch *ds)
static int mv88e6352_setup_global(struct dsa_switch *ds)
{
+ struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret;
int i;
@@ -152,7 +154,7 @@ static int mv88e6352_setup_global(struct dsa_switch *ds)
/* Disable ingress rate limiting by resetting all ingress
* rate limit registers to their initial state.
*/
- for (i = 0; i < 7; i++)
+ for (i = 0; i < ps->num_ports; i++)
REG_WRITE(REG_GLOBAL2, 0x09, 0x9000 | (i << 8));
/* Initialise cross-chip port VLAN table to reset defaults. */
@@ -367,6 +369,8 @@ static int mv88e6352_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
+ ps->num_ports = 7;
+
mutex_init(&ps->eeprom_mutex);
ret = mv88e6352_switch_reset(ds);
@@ -379,7 +383,7 @@ static int mv88e6352_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
- for (i = 0; i < 7; i++) {
+ for (i = 0; i < ps->num_ports; i++) {
ret = mv88e6352_setup_port(ds, i);
if (ret < 0)
return ret;