net: dsa: Consolidate phy read and write functions
Move the common code for reading and writing phy registers into the shared mv88e6xxx. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
4914358567
commit
fd3a0ee406
@@ -321,47 +321,6 @@ static int mv88e6352_setup(struct dsa_switch *ds)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mv88e6352_port_to_phy_addr(int port)
|
||||
{
|
||||
if (port >= 0 && port <= 4)
|
||||
return port;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int
|
||||
mv88e6352_phy_read(struct dsa_switch *ds, int port, int regnum)
|
||||
{
|
||||
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
||||
int addr = mv88e6352_port_to_phy_addr(port);
|
||||
int ret;
|
||||
|
||||
if (addr < 0)
|
||||
return addr;
|
||||
|
||||
mutex_lock(&ps->phy_mutex);
|
||||
ret = mv88e6xxx_phy_read_indirect(ds, addr, regnum);
|
||||
mutex_unlock(&ps->phy_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
mv88e6352_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
|
||||
{
|
||||
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
||||
int addr = mv88e6352_port_to_phy_addr(port);
|
||||
int ret;
|
||||
|
||||
if (addr < 0)
|
||||
return addr;
|
||||
|
||||
mutex_lock(&ps->phy_mutex);
|
||||
ret = mv88e6xxx_phy_write_indirect(ds, addr, regnum, val);
|
||||
mutex_unlock(&ps->phy_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct mv88e6xxx_hw_stat mv88e6352_hw_stats[] = {
|
||||
{ "in_good_octets", 8, 0x00, },
|
||||
{ "in_bad_octets", 4, 0x02, },
|
||||
@@ -621,8 +580,8 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
|
||||
.probe = mv88e6352_probe,
|
||||
.setup = mv88e6352_setup,
|
||||
.set_addr = mv88e6xxx_set_addr_indirect,
|
||||
.phy_read = mv88e6352_phy_read,
|
||||
.phy_write = mv88e6352_phy_write,
|
||||
.phy_read = mv88e6xxx_phy_read_indirect,
|
||||
.phy_write = mv88e6xxx_phy_write_indirect,
|
||||
.poll_link = mv88e6xxx_poll_link,
|
||||
.get_strings = mv88e6352_get_strings,
|
||||
.get_ethtool_stats = mv88e6352_get_ethtool_stats,
|
||||
|
Reference in New Issue
Block a user