diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2016-06-20 13:14:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-06-21 03:58:29 -0400 |
commit | 9f8b3ee1b5be49f5757fd60c22c921ad3ef58585 (patch) | |
tree | af23326dfa5891d7067b1d26ae250076528f2a37 /drivers/net/dsa | |
parent | 5f7c036719536362f293c03c951f36a0509e7aec (diff) |
net: dsa: mv88e6xxx: rename smi_mutex to reg_lock
The chip smi_mutex mutex is used to protect the access to the internal
switch registers, not only the Multi-chip Addressing Mode, as commented.
Since we will isolate SMI-specific pieces of code, avoid the confusion
now by renaming smi_mutex to reg_lock. No functional changes here.
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>
Diffstat (limited to 'drivers/net/dsa')
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.c | 120 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.h | 7 |
2 files changed, 62 insertions, 65 deletions
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index 75e540881077..2c8617275d25 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c | |||
@@ -29,10 +29,10 @@ | |||
29 | #include <net/switchdev.h> | 29 | #include <net/switchdev.h> |
30 | #include "mv88e6xxx.h" | 30 | #include "mv88e6xxx.h" |
31 | 31 | ||
32 | static void assert_smi_lock(struct mv88e6xxx_priv_state *ps) | 32 | static void assert_reg_lock(struct mv88e6xxx_priv_state *ps) |
33 | { | 33 | { |
34 | if (unlikely(!mutex_is_locked(&ps->smi_mutex))) { | 34 | if (unlikely(!mutex_is_locked(&ps->reg_lock))) { |
35 | dev_err(ps->dev, "SMI lock not held!\n"); | 35 | dev_err(ps->dev, "Switch registers lock not held!\n"); |
36 | dump_stack(); | 36 | dump_stack(); |
37 | } | 37 | } |
38 | } | 38 | } |
@@ -99,7 +99,7 @@ static int _mv88e6xxx_reg_read(struct mv88e6xxx_priv_state *ps, | |||
99 | { | 99 | { |
100 | int ret; | 100 | int ret; |
101 | 101 | ||
102 | assert_smi_lock(ps); | 102 | assert_reg_lock(ps); |
103 | 103 | ||
104 | ret = __mv88e6xxx_reg_read(ps->bus, ps->sw_addr, addr, reg); | 104 | ret = __mv88e6xxx_reg_read(ps->bus, ps->sw_addr, addr, reg); |
105 | if (ret < 0) | 105 | if (ret < 0) |
@@ -116,9 +116,9 @@ static int mv88e6xxx_reg_read(struct mv88e6xxx_priv_state *ps, int addr, | |||
116 | { | 116 | { |
117 | int ret; | 117 | int ret; |
118 | 118 | ||
119 | mutex_lock(&ps->smi_mutex); | 119 | mutex_lock(&ps->reg_lock); |
120 | ret = _mv88e6xxx_reg_read(ps, addr, reg); | 120 | ret = _mv88e6xxx_reg_read(ps, addr, reg); |
121 | mutex_unlock(&ps->smi_mutex); | 121 | mutex_unlock(&ps->reg_lock); |
122 | 122 | ||
123 | return ret; | 123 | return ret; |
124 | } | 124 | } |
@@ -158,7 +158,7 @@ static int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr, | |||
158 | static int _mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr, | 158 | static int _mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr, |
159 | int reg, u16 val) | 159 | int reg, u16 val) |
160 | { | 160 | { |
161 | assert_smi_lock(ps); | 161 | assert_reg_lock(ps); |
162 | 162 | ||
163 | dev_dbg(ps->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", | 163 | dev_dbg(ps->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", |
164 | addr, reg, val); | 164 | addr, reg, val); |
@@ -171,9 +171,9 @@ static int mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr, | |||
171 | { | 171 | { |
172 | int ret; | 172 | int ret; |
173 | 173 | ||
174 | mutex_lock(&ps->smi_mutex); | 174 | mutex_lock(&ps->reg_lock); |
175 | ret = _mv88e6xxx_reg_write(ps, addr, reg, val); | 175 | ret = _mv88e6xxx_reg_write(ps, addr, reg, val); |
176 | mutex_unlock(&ps->smi_mutex); | 176 | mutex_unlock(&ps->reg_lock); |
177 | 177 | ||
178 | return ret; | 178 | return ret; |
179 | } | 179 | } |
@@ -320,7 +320,7 @@ static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly) | |||
320 | 320 | ||
321 | ps = container_of(ugly, struct mv88e6xxx_priv_state, ppu_work); | 321 | ps = container_of(ugly, struct mv88e6xxx_priv_state, ppu_work); |
322 | 322 | ||
323 | mutex_lock(&ps->smi_mutex); | 323 | mutex_lock(&ps->reg_lock); |
324 | 324 | ||
325 | if (mutex_trylock(&ps->ppu_mutex)) { | 325 | if (mutex_trylock(&ps->ppu_mutex)) { |
326 | if (mv88e6xxx_ppu_enable(ps) == 0) | 326 | if (mv88e6xxx_ppu_enable(ps) == 0) |
@@ -328,7 +328,7 @@ static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly) | |||
328 | mutex_unlock(&ps->ppu_mutex); | 328 | mutex_unlock(&ps->ppu_mutex); |
329 | } | 329 | } |
330 | 330 | ||
331 | mutex_unlock(&ps->smi_mutex); | 331 | mutex_unlock(&ps->reg_lock); |
332 | } | 332 | } |
333 | 333 | ||
334 | static void mv88e6xxx_ppu_reenable_timer(unsigned long _ps) | 334 | static void mv88e6xxx_ppu_reenable_timer(unsigned long _ps) |
@@ -477,7 +477,7 @@ static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port, | |||
477 | if (!phy_is_pseudo_fixed_link(phydev)) | 477 | if (!phy_is_pseudo_fixed_link(phydev)) |
478 | return; | 478 | return; |
479 | 479 | ||
480 | mutex_lock(&ps->smi_mutex); | 480 | mutex_lock(&ps->reg_lock); |
481 | 481 | ||
482 | ret = _mv88e6xxx_reg_read(ps, REG_PORT(port), PORT_PCS_CTRL); | 482 | ret = _mv88e6xxx_reg_read(ps, REG_PORT(port), PORT_PCS_CTRL); |
483 | if (ret < 0) | 483 | if (ret < 0) |
@@ -528,7 +528,7 @@ static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port, | |||
528 | _mv88e6xxx_reg_write(ps, REG_PORT(port), PORT_PCS_CTRL, reg); | 528 | _mv88e6xxx_reg_write(ps, REG_PORT(port), PORT_PCS_CTRL, reg); |
529 | 529 | ||
530 | out: | 530 | out: |
531 | mutex_unlock(&ps->smi_mutex); | 531 | mutex_unlock(&ps->reg_lock); |
532 | } | 532 | } |
533 | 533 | ||
534 | static int _mv88e6xxx_stats_wait(struct mv88e6xxx_priv_state *ps) | 534 | static int _mv88e6xxx_stats_wait(struct mv88e6xxx_priv_state *ps) |
@@ -753,11 +753,11 @@ static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, | |||
753 | int ret; | 753 | int ret; |
754 | int i, j; | 754 | int i, j; |
755 | 755 | ||
756 | mutex_lock(&ps->smi_mutex); | 756 | mutex_lock(&ps->reg_lock); |
757 | 757 | ||
758 | ret = _mv88e6xxx_stats_snapshot(ps, port); | 758 | ret = _mv88e6xxx_stats_snapshot(ps, port); |
759 | if (ret < 0) { | 759 | if (ret < 0) { |
760 | mutex_unlock(&ps->smi_mutex); | 760 | mutex_unlock(&ps->reg_lock); |
761 | return; | 761 | return; |
762 | } | 762 | } |
763 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { | 763 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
@@ -768,7 +768,7 @@ static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, | |||
768 | } | 768 | } |
769 | } | 769 | } |
770 | 770 | ||
771 | mutex_unlock(&ps->smi_mutex); | 771 | mutex_unlock(&ps->reg_lock); |
772 | } | 772 | } |
773 | 773 | ||
774 | static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) | 774 | static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) |
@@ -787,7 +787,7 @@ static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, | |||
787 | 787 | ||
788 | memset(p, 0xff, 32 * sizeof(u16)); | 788 | memset(p, 0xff, 32 * sizeof(u16)); |
789 | 789 | ||
790 | mutex_lock(&ps->smi_mutex); | 790 | mutex_lock(&ps->reg_lock); |
791 | 791 | ||
792 | for (i = 0; i < 32; i++) { | 792 | for (i = 0; i < 32; i++) { |
793 | int ret; | 793 | int ret; |
@@ -797,7 +797,7 @@ static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, | |||
797 | p[i] = ret; | 797 | p[i] = ret; |
798 | } | 798 | } |
799 | 799 | ||
800 | mutex_unlock(&ps->smi_mutex); | 800 | mutex_unlock(&ps->reg_lock); |
801 | } | 801 | } |
802 | 802 | ||
803 | static int _mv88e6xxx_wait(struct mv88e6xxx_priv_state *ps, int reg, int offset, | 803 | static int _mv88e6xxx_wait(struct mv88e6xxx_priv_state *ps, int reg, int offset, |
@@ -824,9 +824,9 @@ static int mv88e6xxx_wait(struct mv88e6xxx_priv_state *ps, int reg, | |||
824 | { | 824 | { |
825 | int ret; | 825 | int ret; |
826 | 826 | ||
827 | mutex_lock(&ps->smi_mutex); | 827 | mutex_lock(&ps->reg_lock); |
828 | ret = _mv88e6xxx_wait(ps, reg, offset, mask); | 828 | ret = _mv88e6xxx_wait(ps, reg, offset, mask); |
829 | mutex_unlock(&ps->smi_mutex); | 829 | mutex_unlock(&ps->reg_lock); |
830 | 830 | ||
831 | return ret; | 831 | return ret; |
832 | } | 832 | } |
@@ -1123,7 +1123,7 @@ static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, | |||
1123 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE)) | 1123 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE)) |
1124 | return -EOPNOTSUPP; | 1124 | return -EOPNOTSUPP; |
1125 | 1125 | ||
1126 | mutex_lock(&ps->smi_mutex); | 1126 | mutex_lock(&ps->reg_lock); |
1127 | 1127 | ||
1128 | reg = mv88e6xxx_mdio_read_indirect(ps, port, 16); | 1128 | reg = mv88e6xxx_mdio_read_indirect(ps, port, 16); |
1129 | if (reg < 0) | 1129 | if (reg < 0) |
@@ -1140,7 +1140,7 @@ static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, | |||
1140 | reg = 0; | 1140 | reg = 0; |
1141 | 1141 | ||
1142 | out: | 1142 | out: |
1143 | mutex_unlock(&ps->smi_mutex); | 1143 | mutex_unlock(&ps->reg_lock); |
1144 | return reg; | 1144 | return reg; |
1145 | } | 1145 | } |
1146 | 1146 | ||
@@ -1154,7 +1154,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, | |||
1154 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE)) | 1154 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE)) |
1155 | return -EOPNOTSUPP; | 1155 | return -EOPNOTSUPP; |
1156 | 1156 | ||
1157 | mutex_lock(&ps->smi_mutex); | 1157 | mutex_lock(&ps->reg_lock); |
1158 | 1158 | ||
1159 | ret = mv88e6xxx_mdio_read_indirect(ps, port, 16); | 1159 | ret = mv88e6xxx_mdio_read_indirect(ps, port, 16); |
1160 | if (ret < 0) | 1160 | if (ret < 0) |
@@ -1168,7 +1168,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, | |||
1168 | 1168 | ||
1169 | ret = mv88e6xxx_mdio_write_indirect(ps, port, 16, reg); | 1169 | ret = mv88e6xxx_mdio_write_indirect(ps, port, 16, reg); |
1170 | out: | 1170 | out: |
1171 | mutex_unlock(&ps->smi_mutex); | 1171 | mutex_unlock(&ps->reg_lock); |
1172 | 1172 | ||
1173 | return ret; | 1173 | return ret; |
1174 | } | 1174 | } |
@@ -1402,9 +1402,9 @@ static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, | |||
1402 | break; | 1402 | break; |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | mutex_lock(&ps->smi_mutex); | 1405 | mutex_lock(&ps->reg_lock); |
1406 | err = _mv88e6xxx_port_state(ps, port, stp_state); | 1406 | err = _mv88e6xxx_port_state(ps, port, stp_state); |
1407 | mutex_unlock(&ps->smi_mutex); | 1407 | mutex_unlock(&ps->reg_lock); |
1408 | 1408 | ||
1409 | if (err) | 1409 | if (err) |
1410 | netdev_err(ds->ports[port].netdev, | 1410 | netdev_err(ds->ports[port].netdev, |
@@ -1638,7 +1638,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port, | |||
1638 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) | 1638 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) |
1639 | return -EOPNOTSUPP; | 1639 | return -EOPNOTSUPP; |
1640 | 1640 | ||
1641 | mutex_lock(&ps->smi_mutex); | 1641 | mutex_lock(&ps->reg_lock); |
1642 | 1642 | ||
1643 | err = _mv88e6xxx_port_pvid_get(ps, port, &pvid); | 1643 | err = _mv88e6xxx_port_pvid_get(ps, port, &pvid); |
1644 | if (err) | 1644 | if (err) |
@@ -1676,7 +1676,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port, | |||
1676 | } while (next.vid < GLOBAL_VTU_VID_MASK); | 1676 | } while (next.vid < GLOBAL_VTU_VID_MASK); |
1677 | 1677 | ||
1678 | unlock: | 1678 | unlock: |
1679 | mutex_unlock(&ps->smi_mutex); | 1679 | mutex_unlock(&ps->reg_lock); |
1680 | 1680 | ||
1681 | return err; | 1681 | return err; |
1682 | } | 1682 | } |
@@ -2004,7 +2004,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, | |||
2004 | if (!vid_begin) | 2004 | if (!vid_begin) |
2005 | return -EOPNOTSUPP; | 2005 | return -EOPNOTSUPP; |
2006 | 2006 | ||
2007 | mutex_lock(&ps->smi_mutex); | 2007 | mutex_lock(&ps->reg_lock); |
2008 | 2008 | ||
2009 | err = _mv88e6xxx_vtu_vid_write(ps, vid_begin - 1); | 2009 | err = _mv88e6xxx_vtu_vid_write(ps, vid_begin - 1); |
2010 | if (err) | 2010 | if (err) |
@@ -2043,7 +2043,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, | |||
2043 | } while (vlan.vid < vid_end); | 2043 | } while (vlan.vid < vid_end); |
2044 | 2044 | ||
2045 | unlock: | 2045 | unlock: |
2046 | mutex_unlock(&ps->smi_mutex); | 2046 | mutex_unlock(&ps->reg_lock); |
2047 | 2047 | ||
2048 | return err; | 2048 | return err; |
2049 | } | 2049 | } |
@@ -2066,7 +2066,7 @@ static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, | |||
2066 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) | 2066 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) |
2067 | return -EOPNOTSUPP; | 2067 | return -EOPNOTSUPP; |
2068 | 2068 | ||
2069 | mutex_lock(&ps->smi_mutex); | 2069 | mutex_lock(&ps->reg_lock); |
2070 | 2070 | ||
2071 | ret = _mv88e6xxx_reg_read(ps, REG_PORT(port), PORT_CONTROL_2); | 2071 | ret = _mv88e6xxx_reg_read(ps, REG_PORT(port), PORT_CONTROL_2); |
2072 | if (ret < 0) | 2072 | if (ret < 0) |
@@ -2090,7 +2090,7 @@ static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, | |||
2090 | 2090 | ||
2091 | ret = 0; | 2091 | ret = 0; |
2092 | unlock: | 2092 | unlock: |
2093 | mutex_unlock(&ps->smi_mutex); | 2093 | mutex_unlock(&ps->reg_lock); |
2094 | 2094 | ||
2095 | return ret; | 2095 | return ret; |
2096 | } | 2096 | } |
@@ -2149,7 +2149,7 @@ static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, | |||
2149 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) | 2149 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) |
2150 | return; | 2150 | return; |
2151 | 2151 | ||
2152 | mutex_lock(&ps->smi_mutex); | 2152 | mutex_lock(&ps->reg_lock); |
2153 | 2153 | ||
2154 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) | 2154 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) |
2155 | if (_mv88e6xxx_port_vlan_add(ps, port, vid, untagged)) | 2155 | if (_mv88e6xxx_port_vlan_add(ps, port, vid, untagged)) |
@@ -2161,7 +2161,7 @@ static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, | |||
2161 | netdev_err(ds->ports[port].netdev, "failed to set PVID %d\n", | 2161 | netdev_err(ds->ports[port].netdev, "failed to set PVID %d\n", |
2162 | vlan->vid_end); | 2162 | vlan->vid_end); |
2163 | 2163 | ||
2164 | mutex_unlock(&ps->smi_mutex); | 2164 | mutex_unlock(&ps->reg_lock); |
2165 | } | 2165 | } |
2166 | 2166 | ||
2167 | static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_priv_state *ps, | 2167 | static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_priv_state *ps, |
@@ -2210,7 +2210,7 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, | |||
2210 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) | 2210 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) |
2211 | return -EOPNOTSUPP; | 2211 | return -EOPNOTSUPP; |
2212 | 2212 | ||
2213 | mutex_lock(&ps->smi_mutex); | 2213 | mutex_lock(&ps->reg_lock); |
2214 | 2214 | ||
2215 | err = _mv88e6xxx_port_pvid_get(ps, port, &pvid); | 2215 | err = _mv88e6xxx_port_pvid_get(ps, port, &pvid); |
2216 | if (err) | 2216 | if (err) |
@@ -2229,7 +2229,7 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, | |||
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | unlock: | 2231 | unlock: |
2232 | mutex_unlock(&ps->smi_mutex); | 2232 | mutex_unlock(&ps->reg_lock); |
2233 | 2233 | ||
2234 | return err; | 2234 | return err; |
2235 | } | 2235 | } |
@@ -2341,11 +2341,11 @@ static void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, | |||
2341 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU)) | 2341 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU)) |
2342 | return; | 2342 | return; |
2343 | 2343 | ||
2344 | mutex_lock(&ps->smi_mutex); | 2344 | mutex_lock(&ps->reg_lock); |
2345 | if (_mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid, state)) | 2345 | if (_mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid, state)) |
2346 | netdev_err(ds->ports[port].netdev, | 2346 | netdev_err(ds->ports[port].netdev, |
2347 | "failed to load MAC address\n"); | 2347 | "failed to load MAC address\n"); |
2348 | mutex_unlock(&ps->smi_mutex); | 2348 | mutex_unlock(&ps->reg_lock); |
2349 | } | 2349 | } |
2350 | 2350 | ||
2351 | static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, | 2351 | static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, |
@@ -2357,10 +2357,10 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, | |||
2357 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU)) | 2357 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU)) |
2358 | return -EOPNOTSUPP; | 2358 | return -EOPNOTSUPP; |
2359 | 2359 | ||
2360 | mutex_lock(&ps->smi_mutex); | 2360 | mutex_lock(&ps->reg_lock); |
2361 | ret = _mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid, | 2361 | ret = _mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid, |
2362 | GLOBAL_ATU_DATA_STATE_UNUSED); | 2362 | GLOBAL_ATU_DATA_STATE_UNUSED); |
2363 | mutex_unlock(&ps->smi_mutex); | 2363 | mutex_unlock(&ps->reg_lock); |
2364 | 2364 | ||
2365 | return ret; | 2365 | return ret; |
2366 | } | 2366 | } |
@@ -2465,7 +2465,7 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, | |||
2465 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU)) | 2465 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU)) |
2466 | return -EOPNOTSUPP; | 2466 | return -EOPNOTSUPP; |
2467 | 2467 | ||
2468 | mutex_lock(&ps->smi_mutex); | 2468 | mutex_lock(&ps->reg_lock); |
2469 | 2469 | ||
2470 | /* Dump port's default Filtering Information Database (VLAN ID 0) */ | 2470 | /* Dump port's default Filtering Information Database (VLAN ID 0) */ |
2471 | err = _mv88e6xxx_port_fid_get(ps, port, &fid); | 2471 | err = _mv88e6xxx_port_fid_get(ps, port, &fid); |
@@ -2496,7 +2496,7 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, | |||
2496 | } while (vlan.vid < GLOBAL_VTU_VID_MASK); | 2496 | } while (vlan.vid < GLOBAL_VTU_VID_MASK); |
2497 | 2497 | ||
2498 | unlock: | 2498 | unlock: |
2499 | mutex_unlock(&ps->smi_mutex); | 2499 | mutex_unlock(&ps->reg_lock); |
2500 | 2500 | ||
2501 | return err; | 2501 | return err; |
2502 | } | 2502 | } |
@@ -2510,7 +2510,7 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, | |||
2510 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VLANTABLE)) | 2510 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VLANTABLE)) |
2511 | return -EOPNOTSUPP; | 2511 | return -EOPNOTSUPP; |
2512 | 2512 | ||
2513 | mutex_lock(&ps->smi_mutex); | 2513 | mutex_lock(&ps->reg_lock); |
2514 | 2514 | ||
2515 | /* Assign the bridge and remap each port's VLANTable */ | 2515 | /* Assign the bridge and remap each port's VLANTable */ |
2516 | ps->ports[port].bridge_dev = bridge; | 2516 | ps->ports[port].bridge_dev = bridge; |
@@ -2523,7 +2523,7 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, | |||
2523 | } | 2523 | } |
2524 | } | 2524 | } |
2525 | 2525 | ||
2526 | mutex_unlock(&ps->smi_mutex); | 2526 | mutex_unlock(&ps->reg_lock); |
2527 | 2527 | ||
2528 | return err; | 2528 | return err; |
2529 | } | 2529 | } |
@@ -2537,7 +2537,7 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port) | |||
2537 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VLANTABLE)) | 2537 | if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VLANTABLE)) |
2538 | return; | 2538 | return; |
2539 | 2539 | ||
2540 | mutex_lock(&ps->smi_mutex); | 2540 | mutex_lock(&ps->reg_lock); |
2541 | 2541 | ||
2542 | /* Unassign the bridge and remap each port's VLANTable */ | 2542 | /* Unassign the bridge and remap each port's VLANTable */ |
2543 | ps->ports[port].bridge_dev = NULL; | 2543 | ps->ports[port].bridge_dev = NULL; |
@@ -2548,7 +2548,7 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port) | |||
2548 | netdev_warn(ds->ports[i].netdev, | 2548 | netdev_warn(ds->ports[i].netdev, |
2549 | "failed to remap\n"); | 2549 | "failed to remap\n"); |
2550 | 2550 | ||
2551 | mutex_unlock(&ps->smi_mutex); | 2551 | mutex_unlock(&ps->reg_lock); |
2552 | } | 2552 | } |
2553 | 2553 | ||
2554 | static int _mv88e6xxx_mdio_page_write(struct mv88e6xxx_priv_state *ps, | 2554 | static int _mv88e6xxx_mdio_page_write(struct mv88e6xxx_priv_state *ps, |
@@ -3139,7 +3139,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) | |||
3139 | if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEPROM)) | 3139 | if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEPROM)) |
3140 | mutex_init(&ps->eeprom_mutex); | 3140 | mutex_init(&ps->eeprom_mutex); |
3141 | 3141 | ||
3142 | mutex_lock(&ps->smi_mutex); | 3142 | mutex_lock(&ps->reg_lock); |
3143 | 3143 | ||
3144 | err = mv88e6xxx_switch_reset(ps); | 3144 | err = mv88e6xxx_switch_reset(ps); |
3145 | if (err) | 3145 | if (err) |
@@ -3156,7 +3156,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) | |||
3156 | } | 3156 | } |
3157 | 3157 | ||
3158 | unlock: | 3158 | unlock: |
3159 | mutex_unlock(&ps->smi_mutex); | 3159 | mutex_unlock(&ps->reg_lock); |
3160 | 3160 | ||
3161 | return err; | 3161 | return err; |
3162 | } | 3162 | } |
@@ -3167,9 +3167,9 @@ static int mv88e6xxx_mdio_page_read(struct dsa_switch *ds, int port, int page, | |||
3167 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | 3167 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
3168 | int ret; | 3168 | int ret; |
3169 | 3169 | ||
3170 | mutex_lock(&ps->smi_mutex); | 3170 | mutex_lock(&ps->reg_lock); |
3171 | ret = _mv88e6xxx_mdio_page_read(ps, port, page, reg); | 3171 | ret = _mv88e6xxx_mdio_page_read(ps, port, page, reg); |
3172 | mutex_unlock(&ps->smi_mutex); | 3172 | mutex_unlock(&ps->reg_lock); |
3173 | 3173 | ||
3174 | return ret; | 3174 | return ret; |
3175 | } | 3175 | } |
@@ -3180,9 +3180,9 @@ static int mv88e6xxx_mdio_page_write(struct dsa_switch *ds, int port, int page, | |||
3180 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); | 3180 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
3181 | int ret; | 3181 | int ret; |
3182 | 3182 | ||
3183 | mutex_lock(&ps->smi_mutex); | 3183 | mutex_lock(&ps->reg_lock); |
3184 | ret = _mv88e6xxx_mdio_page_write(ps, port, page, reg, val); | 3184 | ret = _mv88e6xxx_mdio_page_write(ps, port, page, reg, val); |
3185 | mutex_unlock(&ps->smi_mutex); | 3185 | mutex_unlock(&ps->reg_lock); |
3186 | 3186 | ||
3187 | return ret; | 3187 | return ret; |
3188 | } | 3188 | } |
@@ -3204,7 +3204,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int port, int regnum) | |||
3204 | if (addr < 0) | 3204 | if (addr < 0) |
3205 | return 0xffff; | 3205 | return 0xffff; |
3206 | 3206 | ||
3207 | mutex_lock(&ps->smi_mutex); | 3207 | mutex_lock(&ps->reg_lock); |
3208 | 3208 | ||
3209 | if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU)) | 3209 | if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU)) |
3210 | ret = mv88e6xxx_mdio_read_ppu(ps, addr, regnum); | 3210 | ret = mv88e6xxx_mdio_read_ppu(ps, addr, regnum); |
@@ -3213,7 +3213,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int port, int regnum) | |||
3213 | else | 3213 | else |
3214 | ret = mv88e6xxx_mdio_read_direct(ps, addr, regnum); | 3214 | ret = mv88e6xxx_mdio_read_direct(ps, addr, regnum); |
3215 | 3215 | ||
3216 | mutex_unlock(&ps->smi_mutex); | 3216 | mutex_unlock(&ps->reg_lock); |
3217 | return ret; | 3217 | return ret; |
3218 | } | 3218 | } |
3219 | 3219 | ||
@@ -3227,7 +3227,7 @@ static int mv88e6xxx_mdio_write(struct mii_bus *bus, int port, int regnum, | |||
3227 | if (addr < 0) | 3227 | if (addr < 0) |
3228 | return 0xffff; | 3228 | return 0xffff; |
3229 | 3229 | ||
3230 | mutex_lock(&ps->smi_mutex); | 3230 | mutex_lock(&ps->reg_lock); |
3231 | 3231 | ||
3232 | if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU)) | 3232 | if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU)) |
3233 | ret = mv88e6xxx_mdio_write_ppu(ps, addr, regnum, val); | 3233 | ret = mv88e6xxx_mdio_write_ppu(ps, addr, regnum, val); |
@@ -3236,7 +3236,7 @@ static int mv88e6xxx_mdio_write(struct mii_bus *bus, int port, int regnum, | |||
3236 | else | 3236 | else |
3237 | ret = mv88e6xxx_mdio_write_direct(ps, addr, regnum, val); | 3237 | ret = mv88e6xxx_mdio_write_direct(ps, addr, regnum, val); |
3238 | 3238 | ||
3239 | mutex_unlock(&ps->smi_mutex); | 3239 | mutex_unlock(&ps->reg_lock); |
3240 | return ret; | 3240 | return ret; |
3241 | } | 3241 | } |
3242 | 3242 | ||
@@ -3310,7 +3310,7 @@ static int mv88e61xx_get_temp(struct dsa_switch *ds, int *temp) | |||
3310 | 3310 | ||
3311 | *temp = 0; | 3311 | *temp = 0; |
3312 | 3312 | ||
3313 | mutex_lock(&ps->smi_mutex); | 3313 | mutex_lock(&ps->reg_lock); |
3314 | 3314 | ||
3315 | ret = mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x6); | 3315 | ret = mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x6); |
3316 | if (ret < 0) | 3316 | if (ret < 0) |
@@ -3343,7 +3343,7 @@ static int mv88e61xx_get_temp(struct dsa_switch *ds, int *temp) | |||
3343 | 3343 | ||
3344 | error: | 3344 | error: |
3345 | mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x0); | 3345 | mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x0); |
3346 | mutex_unlock(&ps->smi_mutex); | 3346 | mutex_unlock(&ps->reg_lock); |
3347 | return ret; | 3347 | return ret; |
3348 | } | 3348 | } |
3349 | 3349 | ||
@@ -3637,7 +3637,7 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev, | |||
3637 | ps->sw_addr = sw_addr; | 3637 | ps->sw_addr = sw_addr; |
3638 | ps->info = info; | 3638 | ps->info = info; |
3639 | ps->dev = dsa_dev; | 3639 | ps->dev = dsa_dev; |
3640 | mutex_init(&ps->smi_mutex); | 3640 | mutex_init(&ps->reg_lock); |
3641 | 3641 | ||
3642 | err = mv88e6xxx_mdio_register(ps, NULL); | 3642 | err = mv88e6xxx_mdio_register(ps, NULL); |
3643 | if (err) | 3643 | if (err) |
@@ -3727,7 +3727,7 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev) | |||
3727 | ps->dev = dev; | 3727 | ps->dev = dev; |
3728 | ps->bus = mdiodev->bus; | 3728 | ps->bus = mdiodev->bus; |
3729 | ps->sw_addr = mdiodev->addr; | 3729 | ps->sw_addr = mdiodev->addr; |
3730 | mutex_init(&ps->smi_mutex); | 3730 | mutex_init(&ps->reg_lock); |
3731 | 3731 | ||
3732 | id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID); | 3732 | id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID); |
3733 | if (id < 0) | 3733 | if (id < 0) |
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h index 8221c3c7ec5a..b279f8c3a803 100644 --- a/drivers/net/dsa/mv88e6xxx.h +++ b/drivers/net/dsa/mv88e6xxx.h | |||
@@ -554,11 +554,8 @@ struct mv88e6xxx_priv_state { | |||
554 | /* The device this structure is associated to */ | 554 | /* The device this structure is associated to */ |
555 | struct device *dev; | 555 | struct device *dev; |
556 | 556 | ||
557 | /* When using multi-chip addressing, this mutex protects | 557 | /* This mutex protects the access to the switch registers */ |
558 | * access to the indirect access registers. (In single-chip | 558 | struct mutex reg_lock; |
559 | * mode, this mutex is effectively useless.) | ||
560 | */ | ||
561 | struct mutex smi_mutex; | ||
562 | 559 | ||
563 | /* The MII bus and the address on the bus that is used to | 560 | /* The MII bus and the address on the bus that is used to |
564 | * communication with the switch | 561 | * communication with the switch |