Commit f894c29c authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: mv88e6xxx: use bridge state values

Reuse the BR_STATE_* values to abstract a port STP state value.

This provides shorter names and better control over the DSA switch
operation call.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 31bef4e9
...@@ -915,28 +915,10 @@ static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, ...@@ -915,28 +915,10 @@ static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
u8 state) u8 state)
{ {
struct mv88e6xxx_chip *chip = ds->priv; struct mv88e6xxx_chip *chip = ds->priv;
int stp_state;
int err; int err;
switch (state) {
case BR_STATE_DISABLED:
stp_state = PORT_CONTROL_STATE_DISABLED;
break;
case BR_STATE_BLOCKING:
case BR_STATE_LISTENING:
stp_state = PORT_CONTROL_STATE_BLOCKING;
break;
case BR_STATE_LEARNING:
stp_state = PORT_CONTROL_STATE_LEARNING;
break;
case BR_STATE_FORWARDING:
default:
stp_state = PORT_CONTROL_STATE_FORWARDING;
break;
}
mutex_lock(&chip->reg_lock); mutex_lock(&chip->reg_lock);
err = mv88e6xxx_port_set_state(chip, port, stp_state); err = mv88e6xxx_port_set_state(chip, port, state);
mutex_unlock(&chip->reg_lock); mutex_unlock(&chip->reg_lock);
if (err) if (err)
...@@ -1694,8 +1676,7 @@ static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip) ...@@ -1694,8 +1676,7 @@ static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
/* Set all ports to the Disabled state */ /* Set all ports to the Disabled state */
for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
err = mv88e6xxx_port_set_state(chip, i, err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
PORT_CONTROL_STATE_DISABLED);
if (err) if (err)
return err; return err;
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* (at your option) any later version. * (at your option) any later version.
*/ */
#include <linux/if_bridge.h>
#include <linux/phy.h> #include <linux/phy.h>
#include "chip.h" #include "chip.h"
...@@ -412,6 +413,25 @@ int mv88e6xxx_port_set_state(struct mv88e6xxx_chip *chip, int port, u8 state) ...@@ -412,6 +413,25 @@ int mv88e6xxx_port_set_state(struct mv88e6xxx_chip *chip, int port, u8 state)
return err; return err;
reg &= ~PORT_CONTROL_STATE_MASK; reg &= ~PORT_CONTROL_STATE_MASK;
switch (state) {
case BR_STATE_DISABLED:
state = PORT_CONTROL_STATE_DISABLED;
break;
case BR_STATE_BLOCKING:
case BR_STATE_LISTENING:
state = PORT_CONTROL_STATE_BLOCKING;
break;
case BR_STATE_LEARNING:
state = PORT_CONTROL_STATE_LEARNING;
break;
case BR_STATE_FORWARDING:
state = PORT_CONTROL_STATE_FORWARDING;
break;
default:
return -EINVAL;
}
reg |= state; reg |= state;
err = mv88e6xxx_port_write(chip, port, PORT_CONTROL, reg); err = mv88e6xxx_port_write(chip, port, PORT_CONTROL, reg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment