diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2016-04-17 13:24:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-17 18:54:15 -0400 |
commit | 009a2b9843bf0b1a85fbf79f76e1de4995de527c (patch) | |
tree | 3f4115c51b462c8af9380f535df32a5e91814190 | |
parent | 22356476a86fc569c34cbf209d3a247c01e0ef6d (diff) |
net: dsa: mv88e6xxx: add number of ports to info
Drop the ps->num_ports variable in favor of a new member of the info
structure. This removes the need to assign it at setup time.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/dsa/mv88e6123.c | 16 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6131.c | 22 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6171.c | 7 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6352.c | 8 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.c | 38 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.h | 3 |
6 files changed, 38 insertions, 56 deletions
diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c index 776e6ef3e29c..0bf43bb17993 100644 --- a/drivers/net/dsa/mv88e6123.c +++ b/drivers/net/dsa/mv88e6123.c | |||
@@ -22,14 +22,17 @@ static const struct mv88e6xxx_info mv88e6123_table[] = { | |||
22 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6123, | 22 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6123, |
23 | .family = MV88E6XXX_FAMILY_6165, | 23 | .family = MV88E6XXX_FAMILY_6165, |
24 | .name = "Marvell 88E6123", | 24 | .name = "Marvell 88E6123", |
25 | .num_ports = 3, | ||
25 | }, { | 26 | }, { |
26 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6161, | 27 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6161, |
27 | .family = MV88E6XXX_FAMILY_6165, | 28 | .family = MV88E6XXX_FAMILY_6165, |
28 | .name = "Marvell 88E6161", | 29 | .name = "Marvell 88E6161", |
30 | .num_ports = 6, | ||
29 | }, { | 31 | }, { |
30 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6165, | 32 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6165, |
31 | .family = MV88E6XXX_FAMILY_6165, | 33 | .family = MV88E6XXX_FAMILY_6165, |
32 | .name = "Marvell 88E6165", | 34 | .name = "Marvell 88E6165", |
35 | .num_ports = 6, | ||
33 | } | 36 | } |
34 | }; | 37 | }; |
35 | 38 | ||
@@ -80,25 +83,12 @@ static int mv88e6123_setup_global(struct dsa_switch *ds) | |||
80 | 83 | ||
81 | static int mv88e6123_setup(struct dsa_switch *ds) | 84 | static int mv88e6123_setup(struct dsa_switch *ds) |
82 | { | 85 | { |
83 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | ||
84 | int ret; | 86 | int ret; |
85 | 87 | ||
86 | ret = mv88e6xxx_setup_common(ds); | 88 | ret = mv88e6xxx_setup_common(ds); |
87 | if (ret < 0) | 89 | if (ret < 0) |
88 | return ret; | 90 | return ret; |
89 | 91 | ||
90 | switch (ps->id) { | ||
91 | case PORT_SWITCH_ID_6123: | ||
92 | ps->num_ports = 3; | ||
93 | break; | ||
94 | case PORT_SWITCH_ID_6161: | ||
95 | case PORT_SWITCH_ID_6165: | ||
96 | ps->num_ports = 6; | ||
97 | break; | ||
98 | default: | ||
99 | return -ENODEV; | ||
100 | } | ||
101 | |||
102 | ret = mv88e6xxx_switch_reset(ds, false); | 92 | ret = mv88e6xxx_switch_reset(ds, false); |
103 | if (ret < 0) | 93 | if (ret < 0) |
104 | return ret; | 94 | return ret; |
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c index 1986651ac054..c01bbb1e857e 100644 --- a/drivers/net/dsa/mv88e6131.c +++ b/drivers/net/dsa/mv88e6131.c | |||
@@ -22,18 +22,22 @@ static const struct mv88e6xxx_info mv88e6131_table[] = { | |||
22 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6095, | 22 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6095, |
23 | .family = MV88E6XXX_FAMILY_6095, | 23 | .family = MV88E6XXX_FAMILY_6095, |
24 | .name = "Marvell 88E6095/88E6095F", | 24 | .name = "Marvell 88E6095/88E6095F", |
25 | .num_ports = 11, | ||
25 | }, { | 26 | }, { |
26 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6085, | 27 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6085, |
27 | .family = MV88E6XXX_FAMILY_6097, | 28 | .family = MV88E6XXX_FAMILY_6097, |
28 | .name = "Marvell 88E6085", | 29 | .name = "Marvell 88E6085", |
30 | .num_ports = 10, | ||
29 | }, { | 31 | }, { |
30 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6131, | 32 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6131, |
31 | .family = MV88E6XXX_FAMILY_6185, | 33 | .family = MV88E6XXX_FAMILY_6185, |
32 | .name = "Marvell 88E6131", | 34 | .name = "Marvell 88E6131", |
35 | .num_ports = 8, | ||
33 | }, { | 36 | }, { |
34 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6185, | 37 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6185, |
35 | .family = MV88E6XXX_FAMILY_6185, | 38 | .family = MV88E6XXX_FAMILY_6185, |
36 | .name = "Marvell 88E6185", | 39 | .name = "Marvell 88E6185", |
40 | .num_ports = 10, | ||
37 | } | 41 | } |
38 | }; | 42 | }; |
39 | 43 | ||
@@ -110,7 +114,6 @@ static int mv88e6131_setup_global(struct dsa_switch *ds) | |||
110 | 114 | ||
111 | static int mv88e6131_setup(struct dsa_switch *ds) | 115 | static int mv88e6131_setup(struct dsa_switch *ds) |
112 | { | 116 | { |
113 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | ||
114 | int ret; | 117 | int ret; |
115 | 118 | ||
116 | ret = mv88e6xxx_setup_common(ds); | 119 | ret = mv88e6xxx_setup_common(ds); |
@@ -119,21 +122,6 @@ static int mv88e6131_setup(struct dsa_switch *ds) | |||
119 | 122 | ||
120 | mv88e6xxx_ppu_state_init(ds); | 123 | mv88e6xxx_ppu_state_init(ds); |
121 | 124 | ||
122 | switch (ps->id) { | ||
123 | case PORT_SWITCH_ID_6085: | ||
124 | case PORT_SWITCH_ID_6185: | ||
125 | ps->num_ports = 10; | ||
126 | break; | ||
127 | case PORT_SWITCH_ID_6095: | ||
128 | ps->num_ports = 11; | ||
129 | break; | ||
130 | case PORT_SWITCH_ID_6131: | ||
131 | ps->num_ports = 8; | ||
132 | break; | ||
133 | default: | ||
134 | return -ENODEV; | ||
135 | } | ||
136 | |||
137 | ret = mv88e6xxx_switch_reset(ds, false); | 125 | ret = mv88e6xxx_switch_reset(ds, false); |
138 | if (ret < 0) | 126 | if (ret < 0) |
139 | return ret; | 127 | return ret; |
@@ -149,7 +137,7 @@ static int mv88e6131_port_to_phy_addr(struct dsa_switch *ds, int port) | |||
149 | { | 137 | { |
150 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | 138 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
151 | 139 | ||
152 | if (port >= 0 && port < ps->num_ports) | 140 | if (port >= 0 && port < ps->info->num_ports) |
153 | return port; | 141 | return port; |
154 | 142 | ||
155 | return -EINVAL; | 143 | return -EINVAL; |
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c index 9a3b1e19b01a..172824fe1dc0 100644 --- a/drivers/net/dsa/mv88e6171.c +++ b/drivers/net/dsa/mv88e6171.c | |||
@@ -22,18 +22,22 @@ static const struct mv88e6xxx_info mv88e6171_table[] = { | |||
22 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6171, | 22 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6171, |
23 | .family = MV88E6XXX_FAMILY_6351, | 23 | .family = MV88E6XXX_FAMILY_6351, |
24 | .name = "Marvell 88E6171", | 24 | .name = "Marvell 88E6171", |
25 | .num_ports = 7, | ||
25 | }, { | 26 | }, { |
26 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6175, | 27 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6175, |
27 | .family = MV88E6XXX_FAMILY_6351, | 28 | .family = MV88E6XXX_FAMILY_6351, |
28 | .name = "Marvell 88E6175", | 29 | .name = "Marvell 88E6175", |
30 | .num_ports = 7, | ||
29 | }, { | 31 | }, { |
30 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6350, | 32 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6350, |
31 | .family = MV88E6XXX_FAMILY_6351, | 33 | .family = MV88E6XXX_FAMILY_6351, |
32 | .name = "Marvell 88E6350", | 34 | .name = "Marvell 88E6350", |
35 | .num_ports = 7, | ||
33 | }, { | 36 | }, { |
34 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6351, | 37 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6351, |
35 | .family = MV88E6XXX_FAMILY_6351, | 38 | .family = MV88E6XXX_FAMILY_6351, |
36 | .name = "Marvell 88E6351", | 39 | .name = "Marvell 88E6351", |
40 | .num_ports = 7, | ||
37 | } | 41 | } |
38 | }; | 42 | }; |
39 | 43 | ||
@@ -86,15 +90,12 @@ static int mv88e6171_setup_global(struct dsa_switch *ds) | |||
86 | 90 | ||
87 | static int mv88e6171_setup(struct dsa_switch *ds) | 91 | static int mv88e6171_setup(struct dsa_switch *ds) |
88 | { | 92 | { |
89 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | ||
90 | int ret; | 93 | int ret; |
91 | 94 | ||
92 | ret = mv88e6xxx_setup_common(ds); | 95 | ret = mv88e6xxx_setup_common(ds); |
93 | if (ret < 0) | 96 | if (ret < 0) |
94 | return ret; | 97 | return ret; |
95 | 98 | ||
96 | ps->num_ports = 7; | ||
97 | |||
98 | ret = mv88e6xxx_switch_reset(ds, true); | 99 | ret = mv88e6xxx_switch_reset(ds, true); |
99 | if (ret < 0) | 100 | if (ret < 0) |
100 | return ret; | 101 | return ret; |
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c index bae62eb9c3b5..12b9a7b5cb31 100644 --- a/drivers/net/dsa/mv88e6352.c +++ b/drivers/net/dsa/mv88e6352.c | |||
@@ -27,26 +27,32 @@ static const struct mv88e6xxx_info mv88e6352_table[] = { | |||
27 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6320, | 27 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6320, |
28 | .family = MV88E6XXX_FAMILY_6320, | 28 | .family = MV88E6XXX_FAMILY_6320, |
29 | .name = "Marvell 88E6320", | 29 | .name = "Marvell 88E6320", |
30 | .num_ports = 7, | ||
30 | }, { | 31 | }, { |
31 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6321, | 32 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6321, |
32 | .family = MV88E6XXX_FAMILY_6320, | 33 | .family = MV88E6XXX_FAMILY_6320, |
33 | .name = "Marvell 88E6321", | 34 | .name = "Marvell 88E6321", |
35 | .num_ports = 7, | ||
34 | }, { | 36 | }, { |
35 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6172, | 37 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6172, |
36 | .family = MV88E6XXX_FAMILY_6352, | 38 | .family = MV88E6XXX_FAMILY_6352, |
37 | .name = "Marvell 88E6172", | 39 | .name = "Marvell 88E6172", |
40 | .num_ports = 7, | ||
38 | }, { | 41 | }, { |
39 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6176, | 42 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6176, |
40 | .family = MV88E6XXX_FAMILY_6352, | 43 | .family = MV88E6XXX_FAMILY_6352, |
41 | .name = "Marvell 88E6176", | 44 | .name = "Marvell 88E6176", |
45 | .num_ports = 7, | ||
42 | }, { | 46 | }, { |
43 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6240, | 47 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6240, |
44 | .family = MV88E6XXX_FAMILY_6352, | 48 | .family = MV88E6XXX_FAMILY_6352, |
45 | .name = "Marvell 88E6240", | 49 | .name = "Marvell 88E6240", |
50 | .num_ports = 7, | ||
46 | }, { | 51 | }, { |
47 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6352, | 52 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6352, |
48 | .family = MV88E6XXX_FAMILY_6352, | 53 | .family = MV88E6XXX_FAMILY_6352, |
49 | .name = "Marvell 88E6352", | 54 | .name = "Marvell 88E6352", |
55 | .num_ports = 7, | ||
50 | } | 56 | } |
51 | }; | 57 | }; |
52 | 58 | ||
@@ -104,8 +110,6 @@ static int mv88e6352_setup(struct dsa_switch *ds) | |||
104 | if (ret < 0) | 110 | if (ret < 0) |
105 | return ret; | 111 | return ret; |
106 | 112 | ||
107 | ps->num_ports = 7; | ||
108 | |||
109 | mutex_init(&ps->eeprom_mutex); | 113 | mutex_init(&ps->eeprom_mutex); |
110 | 114 | ||
111 | ret = mv88e6xxx_switch_reset(ds, true); | 115 | ret = mv88e6xxx_switch_reset(ds, true); |
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index 8f8a1cf59fda..c952d91a5b88 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c | |||
@@ -551,7 +551,7 @@ void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port, | |||
551 | reg |= PORT_PCS_CTRL_DUPLEX_FULL; | 551 | reg |= PORT_PCS_CTRL_DUPLEX_FULL; |
552 | 552 | ||
553 | if ((mv88e6xxx_6352_family(ds) || mv88e6xxx_6351_family(ds)) && | 553 | if ((mv88e6xxx_6352_family(ds) || mv88e6xxx_6351_family(ds)) && |
554 | (port >= ps->num_ports - 2)) { | 554 | (port >= ps->info->num_ports - 2)) { |
555 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) | 555 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) |
556 | reg |= PORT_PCS_CTRL_RGMII_DELAY_RXCLK; | 556 | reg |= PORT_PCS_CTRL_RGMII_DELAY_RXCLK; |
557 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) | 557 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) |
@@ -1132,7 +1132,7 @@ static int _mv88e6xxx_port_based_vlan_map(struct dsa_switch *ds, int port) | |||
1132 | { | 1132 | { |
1133 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | 1133 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
1134 | struct net_device *bridge = ps->ports[port].bridge_dev; | 1134 | struct net_device *bridge = ps->ports[port].bridge_dev; |
1135 | const u16 mask = (1 << ps->num_ports) - 1; | 1135 | const u16 mask = (1 << ps->info->num_ports) - 1; |
1136 | u16 output_ports = 0; | 1136 | u16 output_ports = 0; |
1137 | int reg; | 1137 | int reg; |
1138 | int i; | 1138 | int i; |
@@ -1141,7 +1141,7 @@ static int _mv88e6xxx_port_based_vlan_map(struct dsa_switch *ds, int port) | |||
1141 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) { | 1141 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) { |
1142 | output_ports = mask; | 1142 | output_ports = mask; |
1143 | } else { | 1143 | } else { |
1144 | for (i = 0; i < ps->num_ports; ++i) { | 1144 | for (i = 0; i < ps->info->num_ports; ++i) { |
1145 | /* allow sending frames to every group member */ | 1145 | /* allow sending frames to every group member */ |
1146 | if (bridge && ps->ports[i].bridge_dev == bridge) | 1146 | if (bridge && ps->ports[i].bridge_dev == bridge) |
1147 | output_ports |= BIT(i); | 1147 | output_ports |= BIT(i); |
@@ -1282,7 +1282,7 @@ static int _mv88e6xxx_vtu_stu_data_read(struct dsa_switch *ds, | |||
1282 | regs[i] = ret; | 1282 | regs[i] = ret; |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | for (i = 0; i < ps->num_ports; ++i) { | 1285 | for (i = 0; i < ps->info->num_ports; ++i) { |
1286 | unsigned int shift = (i % 4) * 4 + nibble_offset; | 1286 | unsigned int shift = (i % 4) * 4 + nibble_offset; |
1287 | u16 reg = regs[i / 4]; | 1287 | u16 reg = regs[i / 4]; |
1288 | 1288 | ||
@@ -1301,7 +1301,7 @@ static int _mv88e6xxx_vtu_stu_data_write(struct dsa_switch *ds, | |||
1301 | int i; | 1301 | int i; |
1302 | int ret; | 1302 | int ret; |
1303 | 1303 | ||
1304 | for (i = 0; i < ps->num_ports; ++i) { | 1304 | for (i = 0; i < ps->info->num_ports; ++i) { |
1305 | unsigned int shift = (i % 4) * 4 + nibble_offset; | 1305 | unsigned int shift = (i % 4) * 4 + nibble_offset; |
1306 | u8 data = entry->data[i]; | 1306 | u8 data = entry->data[i]; |
1307 | 1307 | ||
@@ -1633,7 +1633,7 @@ static int _mv88e6xxx_fid_new(struct dsa_switch *ds, u16 *fid) | |||
1633 | bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); | 1633 | bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); |
1634 | 1634 | ||
1635 | /* Set every FID bit used by the (un)bridged ports */ | 1635 | /* Set every FID bit used by the (un)bridged ports */ |
1636 | for (i = 0; i < ps->num_ports; ++i) { | 1636 | for (i = 0; i < ps->info->num_ports; ++i) { |
1637 | err = _mv88e6xxx_port_fid_get(ds, i, fid); | 1637 | err = _mv88e6xxx_port_fid_get(ds, i, fid); |
1638 | if (err) | 1638 | if (err) |
1639 | return err; | 1639 | return err; |
@@ -1683,7 +1683,7 @@ static int _mv88e6xxx_vtu_new(struct dsa_switch *ds, u16 vid, | |||
1683 | return err; | 1683 | return err; |
1684 | 1684 | ||
1685 | /* exclude all ports except the CPU and DSA ports */ | 1685 | /* exclude all ports except the CPU and DSA ports */ |
1686 | for (i = 0; i < ps->num_ports; ++i) | 1686 | for (i = 0; i < ps->info->num_ports; ++i) |
1687 | vlan.data[i] = dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i) | 1687 | vlan.data[i] = dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i) |
1688 | ? GLOBAL_VTU_DATA_MEMBER_TAG_UNMODIFIED | 1688 | ? GLOBAL_VTU_DATA_MEMBER_TAG_UNMODIFIED |
1689 | : GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER; | 1689 | : GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
@@ -1772,7 +1772,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, | |||
1772 | if (vlan.vid > vid_end) | 1772 | if (vlan.vid > vid_end) |
1773 | break; | 1773 | break; |
1774 | 1774 | ||
1775 | for (i = 0; i < ps->num_ports; ++i) { | 1775 | for (i = 0; i < ps->info->num_ports; ++i) { |
1776 | if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) | 1776 | if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) |
1777 | continue; | 1777 | continue; |
1778 | 1778 | ||
@@ -1921,7 +1921,7 @@ static int _mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid) | |||
1921 | 1921 | ||
1922 | /* keep the VLAN unless all ports are excluded */ | 1922 | /* keep the VLAN unless all ports are excluded */ |
1923 | vlan.valid = false; | 1923 | vlan.valid = false; |
1924 | for (i = 0; i < ps->num_ports; ++i) { | 1924 | for (i = 0; i < ps->info->num_ports; ++i) { |
1925 | if (dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i)) | 1925 | if (dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i)) |
1926 | continue; | 1926 | continue; |
1927 | 1927 | ||
@@ -2230,11 +2230,11 @@ int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, | |||
2230 | mutex_lock(&ps->smi_mutex); | 2230 | mutex_lock(&ps->smi_mutex); |
2231 | 2231 | ||
2232 | /* Get or create the bridge FID and assign it to the port */ | 2232 | /* Get or create the bridge FID and assign it to the port */ |
2233 | for (i = 0; i < ps->num_ports; ++i) | 2233 | for (i = 0; i < ps->info->num_ports; ++i) |
2234 | if (ps->ports[i].bridge_dev == bridge) | 2234 | if (ps->ports[i].bridge_dev == bridge) |
2235 | break; | 2235 | break; |
2236 | 2236 | ||
2237 | if (i < ps->num_ports) | 2237 | if (i < ps->info->num_ports) |
2238 | err = _mv88e6xxx_port_fid_get(ds, i, &fid); | 2238 | err = _mv88e6xxx_port_fid_get(ds, i, &fid); |
2239 | else | 2239 | else |
2240 | err = _mv88e6xxx_fid_new(ds, &fid); | 2240 | err = _mv88e6xxx_fid_new(ds, &fid); |
@@ -2248,7 +2248,7 @@ int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, | |||
2248 | /* Assign the bridge and remap each port's VLANTable */ | 2248 | /* Assign the bridge and remap each port's VLANTable */ |
2249 | ps->ports[port].bridge_dev = bridge; | 2249 | ps->ports[port].bridge_dev = bridge; |
2250 | 2250 | ||
2251 | for (i = 0; i < ps->num_ports; ++i) { | 2251 | for (i = 0; i < ps->info->num_ports; ++i) { |
2252 | if (ps->ports[i].bridge_dev == bridge) { | 2252 | if (ps->ports[i].bridge_dev == bridge) { |
2253 | err = _mv88e6xxx_port_based_vlan_map(ds, i); | 2253 | err = _mv88e6xxx_port_based_vlan_map(ds, i); |
2254 | if (err) | 2254 | if (err) |
@@ -2279,7 +2279,7 @@ void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port) | |||
2279 | /* Unassign the bridge and remap each port's VLANTable */ | 2279 | /* Unassign the bridge and remap each port's VLANTable */ |
2280 | ps->ports[port].bridge_dev = NULL; | 2280 | ps->ports[port].bridge_dev = NULL; |
2281 | 2281 | ||
2282 | for (i = 0; i < ps->num_ports; ++i) | 2282 | for (i = 0; i < ps->info->num_ports; ++i) |
2283 | if (i == port || ps->ports[i].bridge_dev == bridge) | 2283 | if (i == port || ps->ports[i].bridge_dev == bridge) |
2284 | if (_mv88e6xxx_port_based_vlan_map(ds, i)) | 2284 | if (_mv88e6xxx_port_based_vlan_map(ds, i)) |
2285 | netdev_warn(ds->ports[i], "failed to remap\n"); | 2285 | netdev_warn(ds->ports[i], "failed to remap\n"); |
@@ -2298,7 +2298,7 @@ static void mv88e6xxx_bridge_work(struct work_struct *work) | |||
2298 | 2298 | ||
2299 | mutex_lock(&ps->smi_mutex); | 2299 | mutex_lock(&ps->smi_mutex); |
2300 | 2300 | ||
2301 | for (port = 0; port < ps->num_ports; ++port) | 2301 | for (port = 0; port < ps->info->num_ports; ++port) |
2302 | if (test_and_clear_bit(port, ps->port_state_update_mask) && | 2302 | if (test_and_clear_bit(port, ps->port_state_update_mask) && |
2303 | _mv88e6xxx_port_state(ds, port, ps->ports[port].state)) | 2303 | _mv88e6xxx_port_state(ds, port, ps->ports[port].state)) |
2304 | netdev_warn(ds->ports[port], "failed to update state to %s\n", | 2304 | netdev_warn(ds->ports[port], "failed to update state to %s\n", |
@@ -2630,7 +2630,7 @@ int mv88e6xxx_setup_ports(struct dsa_switch *ds) | |||
2630 | int ret; | 2630 | int ret; |
2631 | int i; | 2631 | int i; |
2632 | 2632 | ||
2633 | for (i = 0; i < ps->num_ports; i++) { | 2633 | for (i = 0; i < ps->info->num_ports; i++) { |
2634 | ret = mv88e6xxx_setup_port(ds, i); | 2634 | ret = mv88e6xxx_setup_port(ds, i); |
2635 | if (ret < 0) | 2635 | if (ret < 0) |
2636 | return ret; | 2636 | return ret; |
@@ -2737,7 +2737,7 @@ int mv88e6xxx_setup_global(struct dsa_switch *ds) | |||
2737 | err = _mv88e6xxx_reg_write(ds, REG_GLOBAL2, GLOBAL2_TRUNK_MASK, | 2737 | err = _mv88e6xxx_reg_write(ds, REG_GLOBAL2, GLOBAL2_TRUNK_MASK, |
2738 | 0x8000 | | 2738 | 0x8000 | |
2739 | (i << GLOBAL2_TRUNK_MASK_NUM_SHIFT) | | 2739 | (i << GLOBAL2_TRUNK_MASK_NUM_SHIFT) | |
2740 | ((1 << ps->num_ports) - 1)); | 2740 | ((1 << ps->info->num_ports) - 1)); |
2741 | if (err) | 2741 | if (err) |
2742 | goto unlock; | 2742 | goto unlock; |
2743 | } | 2743 | } |
@@ -2790,7 +2790,7 @@ int mv88e6xxx_setup_global(struct dsa_switch *ds) | |||
2790 | * ingress rate limit registers to their initial | 2790 | * ingress rate limit registers to their initial |
2791 | * state. | 2791 | * state. |
2792 | */ | 2792 | */ |
2793 | for (i = 0; i < ps->num_ports; i++) { | 2793 | for (i = 0; i < ps->info->num_ports; i++) { |
2794 | err = _mv88e6xxx_reg_write(ds, REG_GLOBAL2, | 2794 | err = _mv88e6xxx_reg_write(ds, REG_GLOBAL2, |
2795 | GLOBAL2_INGRESS_OP, | 2795 | GLOBAL2_INGRESS_OP, |
2796 | 0x9000 | (i << 8)); | 2796 | 0x9000 | (i << 8)); |
@@ -2835,7 +2835,7 @@ int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active) | |||
2835 | mutex_lock(&ps->smi_mutex); | 2835 | mutex_lock(&ps->smi_mutex); |
2836 | 2836 | ||
2837 | /* Set all ports to the disabled state. */ | 2837 | /* Set all ports to the disabled state. */ |
2838 | for (i = 0; i < ps->num_ports; i++) { | 2838 | for (i = 0; i < ps->info->num_ports; i++) { |
2839 | ret = _mv88e6xxx_reg_read(ds, REG_PORT(i), PORT_CONTROL); | 2839 | ret = _mv88e6xxx_reg_read(ds, REG_PORT(i), PORT_CONTROL); |
2840 | if (ret < 0) | 2840 | if (ret < 0) |
2841 | goto unlock; | 2841 | goto unlock; |
@@ -2918,7 +2918,7 @@ static int mv88e6xxx_port_to_phy_addr(struct dsa_switch *ds, int port) | |||
2918 | { | 2918 | { |
2919 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | 2919 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
2920 | 2920 | ||
2921 | if (port >= 0 && port < ps->num_ports) | 2921 | if (port >= 0 && port < ps->info->num_ports) |
2922 | return port; | 2922 | return port; |
2923 | return -EINVAL; | 2923 | return -EINVAL; |
2924 | } | 2924 | } |
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h index b4eec9a8c8ff..801486aefe78 100644 --- a/drivers/net/dsa/mv88e6xxx.h +++ b/drivers/net/dsa/mv88e6xxx.h | |||
@@ -385,6 +385,7 @@ struct mv88e6xxx_info { | |||
385 | enum mv88e6xxx_family family; | 385 | enum mv88e6xxx_family family; |
386 | u16 prod_num; | 386 | u16 prod_num; |
387 | const char *name; | 387 | const char *name; |
388 | unsigned int num_ports; | ||
388 | }; | 389 | }; |
389 | 390 | ||
390 | struct mv88e6xxx_atu_entry { | 391 | struct mv88e6xxx_atu_entry { |
@@ -456,8 +457,6 @@ struct mv88e6xxx_priv_state { | |||
456 | struct mutex eeprom_mutex; | 457 | struct mutex eeprom_mutex; |
457 | 458 | ||
458 | int id; /* switch product id */ | 459 | int id; /* switch product id */ |
459 | int num_ports; /* number of switch ports */ | ||
460 | |||
461 | struct mv88e6xxx_priv_port ports[DSA_MAX_PORTS]; | 460 | struct mv88e6xxx_priv_port ports[DSA_MAX_PORTS]; |
462 | 461 | ||
463 | DECLARE_BITMAP(port_state_update_mask, DSA_MAX_PORTS); | 462 | DECLARE_BITMAP(port_state_update_mask, DSA_MAX_PORTS); |