Commit 8f420456 authored by Oleksij Rempel's avatar Oleksij Rempel Committed by David S. Miller

net: dsa: microchip: allow to pass return values for PHY read/write accesses

PHY access may end with errors on different levels. So, allow to forward
return values where possible.
Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d7539fc2
...@@ -17,8 +17,8 @@ u32 ksz8_get_port_addr(int port, int offset); ...@@ -17,8 +17,8 @@ u32 ksz8_get_port_addr(int port, int offset);
void ksz8_cfg_port_member(struct ksz_device *dev, int port, u8 member); void ksz8_cfg_port_member(struct ksz_device *dev, int port, u8 member);
void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port); void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port);
void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port); void ksz8_port_setup(struct ksz_device *dev, int port, bool cpu_port);
void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val); int ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val);
void ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val); int ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val);
int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr, int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr,
u8 *fid, u8 *src_port, u8 *timestamp, u16 *entries); u8 *fid, u8 *src_port, u8 *timestamp, u16 *entries);
int ksz8_r_sta_mac_table(struct ksz_device *dev, u16 addr, int ksz8_r_sta_mac_table(struct ksz_device *dev, u16 addr,
......
...@@ -552,7 +552,7 @@ static void ksz8_w_vlan_table(struct ksz_device *dev, u16 vid, u16 vlan) ...@@ -552,7 +552,7 @@ static void ksz8_w_vlan_table(struct ksz_device *dev, u16 vid, u16 vlan)
ksz8_w_table(dev, TABLE_VLAN, addr, buf); ksz8_w_table(dev, TABLE_VLAN, addr, buf);
} }
void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) int ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val)
{ {
u8 restart, speed, ctrl, link; u8 restart, speed, ctrl, link;
int processed = true; int processed = true;
...@@ -674,9 +674,11 @@ void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) ...@@ -674,9 +674,11 @@ void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val)
} }
if (processed) if (processed)
*val = data; *val = data;
return 0;
} }
void ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val) int ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val)
{ {
u8 restart, speed, ctrl, data; u8 restart, speed, ctrl, data;
const u16 *regs; const u16 *regs;
...@@ -787,6 +789,8 @@ void ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val) ...@@ -787,6 +789,8 @@ void ksz8_w_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 val)
default: default:
break; break;
} }
return 0;
} }
void ksz8_cfg_port_member(struct ksz_device *dev, int port, u8 member) void ksz8_cfg_port_member(struct ksz_device *dev, int port, u8 member)
......
...@@ -274,7 +274,7 @@ static void ksz9477_r_phy_quirks(struct ksz_device *dev, u16 addr, u16 reg, ...@@ -274,7 +274,7 @@ static void ksz9477_r_phy_quirks(struct ksz_device *dev, u16 addr, u16 reg,
*data &= ~(BMSR_ESTATEN | BMSR_ERCAP); *data &= ~(BMSR_ESTATEN | BMSR_ERCAP);
} }
void ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data) int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data)
{ {
u16 val = 0xffff; u16 val = 0xffff;
...@@ -322,19 +322,23 @@ void ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data) ...@@ -322,19 +322,23 @@ void ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data)
} }
*data = val; *data = val;
return 0;
} }
void ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val) int ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val)
{ {
/* No real PHY after this. */ /* No real PHY after this. */
if (addr >= dev->phy_port_cnt) if (addr >= dev->phy_port_cnt)
return; return 0;
/* No gigabit support. Do not write to this register. */ /* No gigabit support. Do not write to this register. */
if (!dev->info->gbit_capable[addr] && reg == MII_CTRL1000) if (!dev->info->gbit_capable[addr] && reg == MII_CTRL1000)
return; return 0;
ksz_pwrite16(dev, addr, 0x100 + (reg << 1), val); ksz_pwrite16(dev, addr, 0x100 + (reg << 1), val);
return 0;
} }
void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member) void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member)
......
...@@ -16,8 +16,8 @@ u32 ksz9477_get_port_addr(int port, int offset); ...@@ -16,8 +16,8 @@ u32 ksz9477_get_port_addr(int port, int offset);
void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member); void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member);
void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port); void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port);
void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port); void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port);
void ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data); int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data);
void ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val); int ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt); void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u64 *cnt);
void ksz9477_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, void ksz9477_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,
u64 *dropped, u64 *cnt); u64 *dropped, u64 *cnt);
......
...@@ -1132,8 +1132,11 @@ static int ksz_phy_read16(struct dsa_switch *ds, int addr, int reg) ...@@ -1132,8 +1132,11 @@ static int ksz_phy_read16(struct dsa_switch *ds, int addr, int reg)
{ {
struct ksz_device *dev = ds->priv; struct ksz_device *dev = ds->priv;
u16 val = 0xffff; u16 val = 0xffff;
int ret;
dev->dev_ops->r_phy(dev, addr, reg, &val); ret = dev->dev_ops->r_phy(dev, addr, reg, &val);
if (ret)
return ret;
return val; return val;
} }
...@@ -1141,8 +1144,11 @@ static int ksz_phy_read16(struct dsa_switch *ds, int addr, int reg) ...@@ -1141,8 +1144,11 @@ static int ksz_phy_read16(struct dsa_switch *ds, int addr, int reg)
static int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val) static int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val)
{ {
struct ksz_device *dev = ds->priv; struct ksz_device *dev = ds->priv;
int ret;
dev->dev_ops->w_phy(dev, addr, reg, val); ret = dev->dev_ops->w_phy(dev, addr, reg, val);
if (ret)
return ret;
return 0; return 0;
} }
......
...@@ -262,8 +262,8 @@ struct ksz_dev_ops { ...@@ -262,8 +262,8 @@ struct ksz_dev_ops {
void (*flush_dyn_mac_table)(struct ksz_device *dev, int port); void (*flush_dyn_mac_table)(struct ksz_device *dev, int port);
void (*port_cleanup)(struct ksz_device *dev, int port); void (*port_cleanup)(struct ksz_device *dev, int port);
void (*port_setup)(struct ksz_device *dev, int port, bool cpu_port); void (*port_setup)(struct ksz_device *dev, int port, bool cpu_port);
void (*r_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 *val); int (*r_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 *val);
void (*w_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 val); int (*w_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 val);
void (*r_mib_cnt)(struct ksz_device *dev, int port, u16 addr, void (*r_mib_cnt)(struct ksz_device *dev, int port, u16 addr,
u64 *cnt); u64 *cnt);
void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr, void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr,
......
...@@ -12,8 +12,8 @@ void lan937x_port_setup(struct ksz_device *dev, int port, bool cpu_port); ...@@ -12,8 +12,8 @@ void lan937x_port_setup(struct ksz_device *dev, int port, bool cpu_port);
void lan937x_config_cpu_port(struct dsa_switch *ds); void lan937x_config_cpu_port(struct dsa_switch *ds);
int lan937x_switch_init(struct ksz_device *dev); int lan937x_switch_init(struct ksz_device *dev);
void lan937x_switch_exit(struct ksz_device *dev); void lan937x_switch_exit(struct ksz_device *dev);
void lan937x_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data); int lan937x_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data);
void lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val); int lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu); int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu);
void lan937x_phylink_get_caps(struct ksz_device *dev, int port, void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
struct phylink_config *config); struct phylink_config *config);
......
...@@ -128,14 +128,14 @@ static int lan937x_internal_phy_read(struct ksz_device *dev, int addr, int reg, ...@@ -128,14 +128,14 @@ static int lan937x_internal_phy_read(struct ksz_device *dev, int addr, int reg,
return ksz_read16(dev, REG_VPHY_IND_DATA__2, val); return ksz_read16(dev, REG_VPHY_IND_DATA__2, val);
} }
void lan937x_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data) int lan937x_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data)
{ {
lan937x_internal_phy_read(dev, addr, reg, data); return lan937x_internal_phy_read(dev, addr, reg, data);
} }
void lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val) int lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val)
{ {
lan937x_internal_phy_write(dev, addr, reg, val); return lan937x_internal_phy_write(dev, addr, reg, val);
} }
static int lan937x_sw_mdio_read(struct mii_bus *bus, int addr, int regnum) static int lan937x_sw_mdio_read(struct mii_bus *bus, int addr, int regnum)
......
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