diff options
author | Guenter Roeck <linux@roeck-us.net> | 2015-03-26 21:36:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-29 16:23:49 -0400 |
commit | acdaffcc890a29262c9bb47e287b62488c85eb59 (patch) | |
tree | 53f6701ef582afec91dbf5f8e82f1463a33ce2f9 /drivers/net/dsa | |
parent | 5ce58c2f13eaa8ca6d7e1041175433bd8cc55756 (diff) |
net: dsa: mv88e6xxx: Factor out common initialization code
Code used and needed in mv886xxx.c should be initialized there as well,
so factor it out from the individual initialization files.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa')
-rw-r--r-- | drivers/net/dsa/mv88e6123_61_65.c | 7 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6171.c | 8 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6352.c | 7 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.c | 11 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.h | 1 |
5 files changed, 22 insertions, 12 deletions
diff --git a/drivers/net/dsa/mv88e6123_61_65.c b/drivers/net/dsa/mv88e6123_61_65.c index e9c736e1cef3..6ebe57044afc 100644 --- a/drivers/net/dsa/mv88e6123_61_65.c +++ b/drivers/net/dsa/mv88e6123_61_65.c | |||
@@ -293,13 +293,12 @@ static int mv88e6123_61_65_setup_port(struct dsa_switch *ds, int p) | |||
293 | 293 | ||
294 | static int mv88e6123_61_65_setup(struct dsa_switch *ds) | 294 | static int mv88e6123_61_65_setup(struct dsa_switch *ds) |
295 | { | 295 | { |
296 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | ||
297 | int i; | 296 | int i; |
298 | int ret; | 297 | int ret; |
299 | 298 | ||
300 | mutex_init(&ps->smi_mutex); | 299 | ret = mv88e6xxx_setup_common(ds); |
301 | mutex_init(&ps->stats_mutex); | 300 | if (ret < 0) |
302 | mutex_init(&ps->phy_mutex); | 301 | return ret; |
303 | 302 | ||
304 | ret = mv88e6123_61_65_switch_reset(ds); | 303 | ret = mv88e6123_61_65_switch_reset(ds); |
305 | if (ret < 0) | 304 | if (ret < 0) |
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c index 9808c860a797..2f6662c246fa 100644 --- a/drivers/net/dsa/mv88e6171.c +++ b/drivers/net/dsa/mv88e6171.c | |||
@@ -292,12 +292,12 @@ static int mv88e6171_setup_port(struct dsa_switch *ds, int p) | |||
292 | 292 | ||
293 | static int mv88e6171_setup(struct dsa_switch *ds) | 293 | static int mv88e6171_setup(struct dsa_switch *ds) |
294 | { | 294 | { |
295 | struct mv88e6xxx_priv_state *ps = (void *)(ds + 1); | ||
296 | int i; | 295 | int i; |
297 | int ret; | 296 | int ret; |
298 | 297 | ||
299 | mutex_init(&ps->smi_mutex); | 298 | ret = mv88e6xxx_setup_common(ds); |
300 | mutex_init(&ps->stats_mutex); | 299 | if (ret < 0) |
300 | return ret; | ||
301 | 301 | ||
302 | ret = mv88e6171_switch_reset(ds); | 302 | ret = mv88e6171_switch_reset(ds); |
303 | if (ret < 0) | 303 | if (ret < 0) |
@@ -318,8 +318,6 @@ static int mv88e6171_setup(struct dsa_switch *ds) | |||
318 | return ret; | 318 | return ret; |
319 | } | 319 | } |
320 | 320 | ||
321 | mutex_init(&ps->phy_mutex); | ||
322 | |||
323 | return 0; | 321 | return 0; |
324 | } | 322 | } |
325 | 323 | ||
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c index 7bc5998384c6..75cf9e1c5a44 100644 --- a/drivers/net/dsa/mv88e6352.c +++ b/drivers/net/dsa/mv88e6352.c | |||
@@ -385,9 +385,10 @@ static int mv88e6352_setup(struct dsa_switch *ds) | |||
385 | int ret; | 385 | int ret; |
386 | int i; | 386 | int i; |
387 | 387 | ||
388 | mutex_init(&ps->smi_mutex); | 388 | ret = mv88e6xxx_setup_common(ds); |
389 | mutex_init(&ps->stats_mutex); | 389 | if (ret < 0) |
390 | mutex_init(&ps->phy_mutex); | 390 | return ret; |
391 | |||
391 | mutex_init(&ps->eeprom_mutex); | 392 | mutex_init(&ps->eeprom_mutex); |
392 | 393 | ||
393 | ps->id = REG_READ(REG_PORT(0), 0x03) & 0xfff0; | 394 | ps->id = REG_READ(REG_PORT(0), 0x03) & 0xfff0; |
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index c18ffc98aacc..6496beb74510 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c | |||
@@ -700,6 +700,17 @@ int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, | |||
700 | return 0; | 700 | return 0; |
701 | } | 701 | } |
702 | 702 | ||
703 | int mv88e6xxx_setup_common(struct dsa_switch *ds) | ||
704 | { | ||
705 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | ||
706 | |||
707 | mutex_init(&ps->smi_mutex); | ||
708 | mutex_init(&ps->stats_mutex); | ||
709 | mutex_init(&ps->phy_mutex); | ||
710 | |||
711 | return 0; | ||
712 | } | ||
713 | |||
703 | static int __init mv88e6xxx_init(void) | 714 | static int __init mv88e6xxx_init(void) |
704 | { | 715 | { |
705 | #if IS_ENABLED(CONFIG_NET_DSA_MV88E6131) | 716 | #if IS_ENABLED(CONFIG_NET_DSA_MV88E6131) |
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h index 5fd42ced9011..a02d95a9b313 100644 --- a/drivers/net/dsa/mv88e6xxx.h +++ b/drivers/net/dsa/mv88e6xxx.h | |||
@@ -57,6 +57,7 @@ struct mv88e6xxx_hw_stat { | |||
57 | int reg; | 57 | int reg; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | int mv88e6xxx_setup_common(struct dsa_switch *ds); | ||
60 | int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg); | 61 | int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg); |
61 | int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg); | 62 | int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg); |
62 | int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr, | 63 | int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr, |