Re: [PATCH v3 3/3] net: dsa: mv88e6xxx: Support serdes ports on MV88E6123/6131

From: Chris Packham
Date: Tue Oct 20 2020 - 17:24:09 EST



On 20/10/20 11:18 pm, Russell King - ARM Linux admin wrote:
> On Tue, Oct 20, 2020 at 04:45:58PM +1300, Chris Packham wrote:
>> +void mv88e6123_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p)
>> +{
>> + u16 *p = _p;
>> + u16 reg;
>> + int i;
>> +
>> + if (mv88e6xxx_serdes_get_lane(chip, port) == 0)
>> + return;
>> +
>> + for (i = 0; i < 26; i++) {
>> + mv88e6xxx_phy_read(chip, port, i, &reg);
> Shouldn't this deal with a failed read in some way, rather than just
> assigning the last or possibly uninitialised value to p[i] ?

mv88e6390_serdes_get_regs() and mv88e6352_serdes_get_regs() also ignore
the error. The generic mv88e6xxx_get_regs() memsets p[] to 0xff so if
the serdes_get_regs functions just left it alone we'd return 0xffff
which is probably better than repeating the last value although it's
still ambiguous because 0xffff is a valid value for plenty of these
registers.

Since it looks like I need to come up with an alternative to patch #1
I'll concentrate on that but making the serdes_get_regs() a little more
error tolerant is a cleanup I can easily tack on onto this series.