Skip to content

Commit

Permalink
net: dsa: mv88e6xxx: Handle error in serdes_get_regs
Browse files Browse the repository at this point in the history
If the underlying read operation failed we would end up writing stale
data to the supplied buffer. This would end up with the last
successfully read value repeating. Fix this by only writing the data
when we know the read was good. This will mean that failed values will
return 0xffff.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Chris Packham authored and Jakub Kicinski committed Nov 26, 2020
1 parent 5c19bc8 commit 0fd5d79
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/net/dsa/mv88e6xxx/serdes.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,16 @@ void mv88e6352_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p)
{
u16 *p = _p;
u16 reg;
int err;
int i;

if (!mv88e6352_port_has_serdes(chip, port))
return;

for (i = 0 ; i < 32; i++) {
mv88e6352_serdes_read(chip, i, &reg);
p[i] = reg;
err = mv88e6352_serdes_read(chip, i, &reg);
if (!err)
p[i] = reg;
}
}

Expand Down Expand Up @@ -1096,15 +1098,17 @@ void mv88e6390_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p)
u16 *p = _p;
int lane;
u16 reg;
int err;
int i;

lane = mv88e6xxx_serdes_get_lane(chip, port);
if (lane == 0)
return;

for (i = 0 ; i < ARRAY_SIZE(mv88e6390_serdes_regs); i++) {
mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
mv88e6390_serdes_regs[i], &reg);
p[i] = reg;
err = mv88e6390_serdes_read(chip, lane, MDIO_MMD_PHYXS,
mv88e6390_serdes_regs[i], &reg);
if (!err)
p[i] = reg;
}
}

0 comments on commit 0fd5d79

Please sign in to comment.