Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1661594
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH net-next 3/7] net: dsa: mv88e6xxx: use bridge state values |
| Date | 2017-06-08 21:10 +0200 |
| Message-ID | <tQaYH-8eD-29@gated-at.bofh.it> (permalink) |
| References | <tQaYF-8eD-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 23 ++---------------------
drivers/net/dsa/mv88e6xxx/port.c | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 42dd5560c131..916da1e7f25a 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -915,28 +915,10 @@ static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
u8 state)
{
struct mv88e6xxx_chip *chip = ds->priv;
- int stp_state;
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);
- err = mv88e6xxx_port_set_state(chip, port, stp_state);
+ err = mv88e6xxx_port_set_state(chip, port, state);
mutex_unlock(&chip->reg_lock);
if (err)
@@ -1694,8 +1676,7 @@ static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
/* Set all ports to the Disabled state */
for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
- err = mv88e6xxx_port_set_state(chip, i,
- PORT_CONTROL_STATE_DISABLED);
+ err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
if (err)
return err;
}
diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
index 8e49c5584a53..cf19ab22f46e 100644
--- a/drivers/net/dsa/mv88e6xxx/port.c
+++ b/drivers/net/dsa/mv88e6xxx/port.c
@@ -12,6 +12,7 @@
* (at your option) any later version.
*/
+#include <linux/if_bridge.h>
#include <linux/phy.h>
#include "chip.h"
@@ -412,6 +413,25 @@ int mv88e6xxx_port_set_state(struct mv88e6xxx_chip *chip, int port, u8 state)
return err;
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;
err = mv88e6xxx_port_write(chip, port, PORT_CONTROL, reg);
--
2.13.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH net-next 0/7] net: dsa: mv88e6xxx: ops cosmetics Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-06-08 21:10 +0200
[PATCH net-next 6/7] net: dsa: mv88e6xxx: rework jumbo size operation Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-06-08 21:10 +0200
Re: [PATCH net-next 6/7] net: dsa: mv88e6xxx: rework jumbo size operation Andrew Lunn <andrew@lunn.ch> - 2017-06-08 21:50 +0200
[PATCH net-next 3/7] net: dsa: mv88e6xxx: use bridge state values Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-06-08 21:10 +0200
[PATCH net-next 4/7] net: dsa: mv88e6xxx: do not prefix ops with g1 Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-06-08 21:10 +0200
[PATCH net-next 2/7] net: dsa: mv88e6xxx: add egress mode enumeration Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-06-08 21:10 +0200
Re: [PATCH net-next 2/7] net: dsa: mv88e6xxx: add egress mode enumeration Andrew Lunn <andrew@lunn.ch> - 2017-06-08 21:40 +0200
csiph-web