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

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: 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 5f7c0367
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
#include <net/switchdev.h> #include <net/switchdev.h>
#include "mv88e6xxx.h" #include "mv88e6xxx.h"
static void assert_smi_lock(struct mv88e6xxx_priv_state *ps) static void assert_reg_lock(struct mv88e6xxx_priv_state *ps)
{ {
if (unlikely(!mutex_is_locked(&ps->smi_mutex))) { if (unlikely(!mutex_is_locked(&ps->reg_lock))) {
dev_err(ps->dev, "SMI lock not held!\n"); dev_err(ps->dev, "Switch registers lock not held!\n");
dump_stack(); dump_stack();
} }
} }
...@@ -99,7 +99,7 @@ static int _mv88e6xxx_reg_read(struct mv88e6xxx_priv_state *ps, ...@@ -99,7 +99,7 @@ static int _mv88e6xxx_reg_read(struct mv88e6xxx_priv_state *ps,
{ {
int ret; int ret;
assert_smi_lock(ps); assert_reg_lock(ps);
ret = __mv88e6xxx_reg_read(ps->bus, ps->sw_addr, addr, reg); ret = __mv88e6xxx_reg_read(ps->bus, ps->sw_addr, addr, reg);
if (ret < 0) if (ret < 0)
...@@ -116,9 +116,9 @@ static int mv88e6xxx_reg_read(struct mv88e6xxx_priv_state *ps, int addr, ...@@ -116,9 +116,9 @@ static int mv88e6xxx_reg_read(struct mv88e6xxx_priv_state *ps, int addr,
{ {
int ret; int ret;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = _mv88e6xxx_reg_read(ps, addr, reg); ret = _mv88e6xxx_reg_read(ps, addr, reg);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -158,7 +158,7 @@ static int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr, ...@@ -158,7 +158,7 @@ static int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr,
static int _mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr, static int _mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr,
int reg, u16 val) int reg, u16 val)
{ {
assert_smi_lock(ps); assert_reg_lock(ps);
dev_dbg(ps->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", dev_dbg(ps->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
addr, reg, val); addr, reg, val);
...@@ -171,9 +171,9 @@ static int mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr, ...@@ -171,9 +171,9 @@ static int mv88e6xxx_reg_write(struct mv88e6xxx_priv_state *ps, int addr,
{ {
int ret; int ret;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = _mv88e6xxx_reg_write(ps, addr, reg, val); ret = _mv88e6xxx_reg_write(ps, addr, reg, val);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -320,7 +320,7 @@ static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly) ...@@ -320,7 +320,7 @@ static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly)
ps = container_of(ugly, struct mv88e6xxx_priv_state, ppu_work); ps = container_of(ugly, struct mv88e6xxx_priv_state, ppu_work);
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
if (mutex_trylock(&ps->ppu_mutex)) { if (mutex_trylock(&ps->ppu_mutex)) {
if (mv88e6xxx_ppu_enable(ps) == 0) if (mv88e6xxx_ppu_enable(ps) == 0)
...@@ -328,7 +328,7 @@ static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly) ...@@ -328,7 +328,7 @@ static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly)
mutex_unlock(&ps->ppu_mutex); mutex_unlock(&ps->ppu_mutex);
} }
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
} }
static void mv88e6xxx_ppu_reenable_timer(unsigned long _ps) 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,7 +477,7 @@ static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
if (!phy_is_pseudo_fixed_link(phydev)) if (!phy_is_pseudo_fixed_link(phydev))
return; return;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = _mv88e6xxx_reg_read(ps, REG_PORT(port), PORT_PCS_CTRL); ret = _mv88e6xxx_reg_read(ps, REG_PORT(port), PORT_PCS_CTRL);
if (ret < 0) if (ret < 0)
...@@ -528,7 +528,7 @@ static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port, ...@@ -528,7 +528,7 @@ static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
_mv88e6xxx_reg_write(ps, REG_PORT(port), PORT_PCS_CTRL, reg); _mv88e6xxx_reg_write(ps, REG_PORT(port), PORT_PCS_CTRL, reg);
out: out:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
} }
static int _mv88e6xxx_stats_wait(struct mv88e6xxx_priv_state *ps) 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,11 +753,11 @@ static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
int ret; int ret;
int i, j; int i, j;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = _mv88e6xxx_stats_snapshot(ps, port); ret = _mv88e6xxx_stats_snapshot(ps, port);
if (ret < 0) { if (ret < 0) {
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return; return;
} }
for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { 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,7 +768,7 @@ static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
} }
} }
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
} }
static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) 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,7 +787,7 @@ static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
memset(p, 0xff, 32 * sizeof(u16)); memset(p, 0xff, 32 * sizeof(u16));
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
int ret; int ret;
...@@ -797,7 +797,7 @@ static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, ...@@ -797,7 +797,7 @@ static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
p[i] = ret; p[i] = ret;
} }
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
} }
static int _mv88e6xxx_wait(struct mv88e6xxx_priv_state *ps, int reg, int offset, 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,9 +824,9 @@ static int mv88e6xxx_wait(struct mv88e6xxx_priv_state *ps, int reg,
{ {
int ret; int ret;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = _mv88e6xxx_wait(ps, reg, offset, mask); ret = _mv88e6xxx_wait(ps, reg, offset, mask);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -1123,7 +1123,7 @@ static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, ...@@ -1123,7 +1123,7 @@ static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE))
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
reg = mv88e6xxx_mdio_read_indirect(ps, port, 16); reg = mv88e6xxx_mdio_read_indirect(ps, port, 16);
if (reg < 0) if (reg < 0)
...@@ -1140,7 +1140,7 @@ static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, ...@@ -1140,7 +1140,7 @@ static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port,
reg = 0; reg = 0;
out: out:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return reg; return reg;
} }
...@@ -1154,7 +1154,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, ...@@ -1154,7 +1154,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEE))
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = mv88e6xxx_mdio_read_indirect(ps, port, 16); ret = mv88e6xxx_mdio_read_indirect(ps, port, 16);
if (ret < 0) if (ret < 0)
...@@ -1168,7 +1168,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, ...@@ -1168,7 +1168,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
ret = mv88e6xxx_mdio_write_indirect(ps, port, 16, reg); ret = mv88e6xxx_mdio_write_indirect(ps, port, 16, reg);
out: out:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -1402,9 +1402,9 @@ static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, ...@@ -1402,9 +1402,9 @@ static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
break; break;
} }
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
err = _mv88e6xxx_port_state(ps, port, stp_state); err = _mv88e6xxx_port_state(ps, port, stp_state);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
if (err) if (err)
netdev_err(ds->ports[port].netdev, netdev_err(ds->ports[port].netdev,
...@@ -1638,7 +1638,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port, ...@@ -1638,7 +1638,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU))
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
err = _mv88e6xxx_port_pvid_get(ps, port, &pvid); err = _mv88e6xxx_port_pvid_get(ps, port, &pvid);
if (err) if (err)
...@@ -1676,7 +1676,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port, ...@@ -1676,7 +1676,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
} while (next.vid < GLOBAL_VTU_VID_MASK); } while (next.vid < GLOBAL_VTU_VID_MASK);
unlock: unlock:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return err; return err;
} }
...@@ -2004,7 +2004,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, ...@@ -2004,7 +2004,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
if (!vid_begin) if (!vid_begin)
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
err = _mv88e6xxx_vtu_vid_write(ps, vid_begin - 1); err = _mv88e6xxx_vtu_vid_write(ps, vid_begin - 1);
if (err) if (err)
...@@ -2043,7 +2043,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, ...@@ -2043,7 +2043,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
} while (vlan.vid < vid_end); } while (vlan.vid < vid_end);
unlock: unlock:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return err; return err;
} }
...@@ -2066,7 +2066,7 @@ static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, ...@@ -2066,7 +2066,7 @@ static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU))
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = _mv88e6xxx_reg_read(ps, REG_PORT(port), PORT_CONTROL_2); ret = _mv88e6xxx_reg_read(ps, REG_PORT(port), PORT_CONTROL_2);
if (ret < 0) if (ret < 0)
...@@ -2090,7 +2090,7 @@ static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, ...@@ -2090,7 +2090,7 @@ static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
ret = 0; ret = 0;
unlock: unlock:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -2149,7 +2149,7 @@ static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, ...@@ -2149,7 +2149,7 @@ static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU))
return; return;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
if (_mv88e6xxx_port_vlan_add(ps, port, vid, untagged)) 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,7 +2161,7 @@ static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
netdev_err(ds->ports[port].netdev, "failed to set PVID %d\n", netdev_err(ds->ports[port].netdev, "failed to set PVID %d\n",
vlan->vid_end); vlan->vid_end);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
} }
static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_priv_state *ps, 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,7 +2210,7 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VTU))
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
err = _mv88e6xxx_port_pvid_get(ps, port, &pvid); err = _mv88e6xxx_port_pvid_get(ps, port, &pvid);
if (err) if (err)
...@@ -2229,7 +2229,7 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, ...@@ -2229,7 +2229,7 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
} }
unlock: unlock:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return err; return err;
} }
...@@ -2341,11 +2341,11 @@ static void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, ...@@ -2341,11 +2341,11 @@ static void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU))
return; return;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
if (_mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid, state)) if (_mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid, state))
netdev_err(ds->ports[port].netdev, netdev_err(ds->ports[port].netdev,
"failed to load MAC address\n"); "failed to load MAC address\n");
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
} }
static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, 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,10 +2357,10 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU))
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = _mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid, ret = _mv88e6xxx_port_fdb_load(ps, port, fdb->addr, fdb->vid,
GLOBAL_ATU_DATA_STATE_UNUSED); GLOBAL_ATU_DATA_STATE_UNUSED);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -2465,7 +2465,7 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, ...@@ -2465,7 +2465,7 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_ATU))
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
/* Dump port's default Filtering Information Database (VLAN ID 0) */ /* Dump port's default Filtering Information Database (VLAN ID 0) */
err = _mv88e6xxx_port_fid_get(ps, port, &fid); 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,7 +2496,7 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
} while (vlan.vid < GLOBAL_VTU_VID_MASK); } while (vlan.vid < GLOBAL_VTU_VID_MASK);
unlock: unlock:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return err; return err;
} }
...@@ -2510,7 +2510,7 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, ...@@ -2510,7 +2510,7 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VLANTABLE)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VLANTABLE))
return -EOPNOTSUPP; return -EOPNOTSUPP;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
/* Assign the bridge and remap each port's VLANTable */ /* Assign the bridge and remap each port's VLANTable */
ps->ports[port].bridge_dev = bridge; ps->ports[port].bridge_dev = bridge;
...@@ -2523,7 +2523,7 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, ...@@ -2523,7 +2523,7 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
} }
} }
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return err; return err;
} }
...@@ -2537,7 +2537,7 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port) ...@@ -2537,7 +2537,7 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port)
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VLANTABLE)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_VLANTABLE))
return; return;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
/* Unassign the bridge and remap each port's VLANTable */ /* Unassign the bridge and remap each port's VLANTable */
ps->ports[port].bridge_dev = NULL; ps->ports[port].bridge_dev = NULL;
...@@ -2548,7 +2548,7 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port) ...@@ -2548,7 +2548,7 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port)
netdev_warn(ds->ports[i].netdev, netdev_warn(ds->ports[i].netdev,
"failed to remap\n"); "failed to remap\n");
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
} }
static int _mv88e6xxx_mdio_page_write(struct mv88e6xxx_priv_state *ps, static int _mv88e6xxx_mdio_page_write(struct mv88e6xxx_priv_state *ps,
...@@ -3139,7 +3139,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) ...@@ -3139,7 +3139,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEPROM)) if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_EEPROM))
mutex_init(&ps->eeprom_mutex); mutex_init(&ps->eeprom_mutex);
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
err = mv88e6xxx_switch_reset(ps); err = mv88e6xxx_switch_reset(ps);
if (err) if (err)
...@@ -3156,7 +3156,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) ...@@ -3156,7 +3156,7 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
} }
unlock: unlock:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return err; return err;
} }
...@@ -3167,9 +3167,9 @@ static int mv88e6xxx_mdio_page_read(struct dsa_switch *ds, int port, int page, ...@@ -3167,9 +3167,9 @@ static int mv88e6xxx_mdio_page_read(struct dsa_switch *ds, int port, int page,
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret; int ret;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = _mv88e6xxx_mdio_page_read(ps, port, page, reg); ret = _mv88e6xxx_mdio_page_read(ps, port, page, reg);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -3180,9 +3180,9 @@ static int mv88e6xxx_mdio_page_write(struct dsa_switch *ds, int port, int page, ...@@ -3180,9 +3180,9 @@ static int mv88e6xxx_mdio_page_write(struct dsa_switch *ds, int port, int page,
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret; int ret;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = _mv88e6xxx_mdio_page_write(ps, port, page, reg, val); ret = _mv88e6xxx_mdio_page_write(ps, port, page, reg, val);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -3204,7 +3204,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int port, int regnum) ...@@ -3204,7 +3204,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int port, int regnum)
if (addr < 0) if (addr < 0)
return 0xffff; return 0xffff;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU)) if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU))
ret = mv88e6xxx_mdio_read_ppu(ps, addr, regnum); 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,7 +3213,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int port, int regnum)
else else
ret = mv88e6xxx_mdio_read_direct(ps, addr, regnum); ret = mv88e6xxx_mdio_read_direct(ps, addr, regnum);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -3227,7 +3227,7 @@ static int mv88e6xxx_mdio_write(struct mii_bus *bus, int port, int regnum, ...@@ -3227,7 +3227,7 @@ static int mv88e6xxx_mdio_write(struct mii_bus *bus, int port, int regnum,
if (addr < 0) if (addr < 0)
return 0xffff; return 0xffff;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU)) if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU))
ret = mv88e6xxx_mdio_write_ppu(ps, addr, regnum, val); 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,7 +3236,7 @@ static int mv88e6xxx_mdio_write(struct mii_bus *bus, int port, int regnum,
else else
ret = mv88e6xxx_mdio_write_direct(ps, addr, regnum, val); ret = mv88e6xxx_mdio_write_direct(ps, addr, regnum, val);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -3310,7 +3310,7 @@ static int mv88e61xx_get_temp(struct dsa_switch *ds, int *temp) ...@@ -3310,7 +3310,7 @@ static int mv88e61xx_get_temp(struct dsa_switch *ds, int *temp)
*temp = 0; *temp = 0;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->reg_lock);
ret = mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x6); ret = mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x6);
if (ret < 0) if (ret < 0)
...@@ -3343,7 +3343,7 @@ static int mv88e61xx_get_temp(struct dsa_switch *ds, int *temp) ...@@ -3343,7 +3343,7 @@ static int mv88e61xx_get_temp(struct dsa_switch *ds, int *temp)
error: error:
mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x0); mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x0);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->reg_lock);
return ret; return ret;
} }
...@@ -3637,7 +3637,7 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev, ...@@ -3637,7 +3637,7 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
ps->sw_addr = sw_addr; ps->sw_addr = sw_addr;
ps->info = info; ps->info = info;
ps->dev = dsa_dev; ps->dev = dsa_dev;
mutex_init(&ps->smi_mutex); mutex_init(&ps->reg_lock);
err = mv88e6xxx_mdio_register(ps, NULL); err = mv88e6xxx_mdio_register(ps, NULL);
if (err) if (err)
...@@ -3727,7 +3727,7 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev) ...@@ -3727,7 +3727,7 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
ps->dev = dev; ps->dev = dev;
ps->bus = mdiodev->bus; ps->bus = mdiodev->bus;
ps->sw_addr = mdiodev->addr; ps->sw_addr = mdiodev->addr;
mutex_init(&ps->smi_mutex); mutex_init(&ps->reg_lock);
id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID); id = mv88e6xxx_reg_read(ps, REG_PORT(0), PORT_SWITCH_ID);
if (id < 0) if (id < 0)
......
...@@ -554,11 +554,8 @@ struct mv88e6xxx_priv_state { ...@@ -554,11 +554,8 @@ struct mv88e6xxx_priv_state {
/* The device this structure is associated to */ /* The device this structure is associated to */
struct device *dev; struct device *dev;
/* When using multi-chip addressing, this mutex protects /* This mutex protects the access to the switch registers */
* access to the indirect access registers. (In single-chip struct mutex reg_lock;
* mode, this mutex is effectively useless.)
*/
struct mutex smi_mutex;
/* The MII bus and the address on the bus that is used to /* The MII bus and the address on the bus that is used to
* communication with the switch * communication with the switch
......
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