Skip to content

Commit

Permalink
net: dsa: mv88e6xxx: Add helper to determining if port has SERDES
Browse files Browse the repository at this point in the history
Refactor the existing code. This helper will be used for SERDES
statistics.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Andrew Lunn authored and David S. Miller committed Mar 4, 2018
1 parent 436fe17 commit eb755c3
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions drivers/net/dsa/mv88e6xxx/serdes.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,30 @@ static int mv88e6352_serdes_power_set(struct mv88e6xxx_chip *chip, bool on)
return err;
}

int mv88e6352_serdes_power(struct mv88e6xxx_chip *chip, int port, bool on)
static bool mv88e6352_port_has_serdes(struct mv88e6xxx_chip *chip, int port)
{
int err;
u8 cmode;
int err;

err = mv88e6xxx_port_get_cmode(chip, port, &cmode);
if (err)
return err;
if (err) {
dev_err(chip->dev, "failed to read cmode\n");
return 0;
}

if ((cmode == MV88E6XXX_PORT_STS_CMODE_100BASE_X) ||
(cmode == MV88E6XXX_PORT_STS_CMODE_1000BASE_X) ||
(cmode == MV88E6XXX_PORT_STS_CMODE_SGMII)) {
(cmode == MV88E6XXX_PORT_STS_CMODE_SGMII))
return 1;

return 0;
}

int mv88e6352_serdes_power(struct mv88e6xxx_chip *chip, int port, bool on)
{
int err;

if (mv88e6352_port_has_serdes(chip, port)) {
err = mv88e6352_serdes_power_set(chip, on);
if (err < 0)
return err;
Expand Down

0 comments on commit eb755c3

Please sign in to comment.