Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbde9e66 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller
Browse files

net: dsa: Centralize setting up ports



Now that setting up a port is identical for all switches, centralisers
the code looping over all the ports to set them up.

Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 54d792f2
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ static int mv88e6123_61_65_setup_global(struct dsa_switch *ds)
static int mv88e6123_61_65_setup(struct dsa_switch *ds)
{
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int i;
	int ret;

	ret = mv88e6xxx_setup_common(ds);
@@ -110,13 +109,7 @@ static int mv88e6123_61_65_setup(struct dsa_switch *ds)
	if (ret < 0)
		return ret;

	for (i = 0; i < ps->num_ports; i++) {
		ret = mv88e6xxx_setup_port(ds, i);
		if (ret < 0)
			return ret;
	}

	return 0;
	return mv88e6xxx_setup_ports(ds);
}

struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
+1 −8
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ static int mv88e6131_setup_global(struct dsa_switch *ds)
static int mv88e6131_setup(struct dsa_switch *ds)
{
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int i;
	int ret;

	ret = mv88e6xxx_setup_common(ds);
@@ -118,13 +117,7 @@ static int mv88e6131_setup(struct dsa_switch *ds)
	if (ret < 0)
		return ret;

	for (i = 0; i < ps->num_ports; i++) {
		ret = mv88e6xxx_setup_port(ds, i);
		if (ret < 0)
			return ret;
	}

	return 0;
	return mv88e6xxx_setup_ports(ds);
}

static int mv88e6131_port_to_phy_addr(struct dsa_switch *ds, int port)
+1 −11
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ static int mv88e6171_setup_global(struct dsa_switch *ds)
static int mv88e6171_setup(struct dsa_switch *ds)
{
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int i;
	int ret;

	ret = mv88e6xxx_setup_common(ds);
@@ -86,16 +85,7 @@ static int mv88e6171_setup(struct dsa_switch *ds)
	if (ret < 0)
		return ret;

	for (i = 0; i < ps->num_ports; i++) {
		if (!(dsa_is_cpu_port(ds, i) || ds->phys_port_mask & (1 << i)))
			continue;

		ret = mv88e6xxx_setup_port(ds, i);
		if (ret < 0)
			return ret;
	}

	return 0;
	return mv88e6xxx_setup_ports(ds);
}

static int mv88e6171_get_eee(struct dsa_switch *ds, int port,
+1 −8
Original line number Diff line number Diff line
@@ -136,7 +136,6 @@ static int mv88e6352_setup(struct dsa_switch *ds)
{
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int ret;
	int i;

	ret = mv88e6xxx_setup_common(ds);
	if (ret < 0)
@@ -154,13 +153,7 @@ static int mv88e6352_setup(struct dsa_switch *ds)
	if (ret < 0)
		return ret;

	for (i = 0; i < ps->num_ports; i++) {
		ret = mv88e6xxx_setup_port(ds, i);
		if (ret < 0)
			return ret;
	}

	return 0;
	return mv88e6xxx_setup_ports(ds);
}

static int mv88e6352_read_eeprom_word(struct dsa_switch *ds, int addr)
+15 −1
Original line number Diff line number Diff line
@@ -1309,7 +1309,7 @@ static void mv88e6xxx_bridge_work(struct work_struct *work)
	}
}

int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
static int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
{
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int ret, fid;
@@ -1548,6 +1548,20 @@ int mv88e6xxx_setup_port(struct dsa_switch *ds, int port)
	return ret;
}

int mv88e6xxx_setup_ports(struct dsa_switch *ds)
{
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int ret;
	int i;

	for (i = 0; i < ps->num_ports; i++) {
		ret = mv88e6xxx_setup_port(ds, i);
		if (ret < 0)
			return ret;
	}
	return 0;
}

int mv88e6xxx_setup_common(struct dsa_switch *ds)
{
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
Loading