diff options
author | Andrew Lunn <andrew@lunn.ch> | 2018-03-01 02:02:30 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-03-04 13:34:18 -0500 |
commit | eb755c3f6b7deb22ed19e2d3cc4418d3ae510196 (patch) | |
tree | cc54a46aabef683aa63857f90a95b6f3f309c3da /drivers/net/dsa/mv88e6xxx | |
parent | 436fe17d273bed9fd8b7bdf4172ea6d9eac0b703 (diff) | |
download | linux-stable-eb755c3f6b7deb22ed19e2d3cc4418d3ae510196.tar.gz linux-stable-eb755c3f6b7deb22ed19e2d3cc4418d3ae510196.tar.bz2 linux-stable-eb755c3f6b7deb22ed19e2d3cc4418d3ae510196.zip |
net: dsa: mv88e6xxx: Add helper to determining if port has SERDES
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>
Diffstat (limited to 'drivers/net/dsa/mv88e6xxx')
-rw-r--r-- | drivers/net/dsa/mv88e6xxx/serdes.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c index f3c01119b3d1..4487d18132a4 100644 --- a/drivers/net/dsa/mv88e6xxx/serdes.c +++ b/drivers/net/dsa/mv88e6xxx/serdes.c @@ -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; |