The power class read from the classification register is not 1:1 aligned with the IEEE 802.3 class value. Add a lookup table to report the correct class. Fixes: 7f076ce3f1733 ("net: pse-pd: tps23881: Add support for power limit and measurement features") Signed-off-by: Kory Maincent --- drivers/net/pse-pd/tps23881.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c index 244ce596d845c..58ea7e0ffa996 100644 --- a/drivers/net/pse-pd/tps23881.c +++ b/drivers/net/pse-pd/tps23881.c @@ -402,6 +402,25 @@ tps23881_pi_get_chan_current(struct tps23881_priv *priv, u8 chan) return (int)tmp_64; } +static int tps23881_class_table[] = { + -ERANGE, + 1, + 2, + 3, + 4, + 0, + 0, + -ERANGE, + 5, + 6, + 7, + 8, + 4, + 5, + -ERANGE, + -ERANGE, +}; + static int tps23881_pi_get_pw_class(struct pse_controller_dev *pcdev, int id) { @@ -416,7 +435,8 @@ static int tps23881_pi_get_pw_class(struct pse_controller_dev *pcdev, if (ret < 0) return ret; - return tps23881_calc_val(ret, chan, 4, 0x0f); + ret = tps23881_calc_val(ret, chan, 4, 0x0f); + return tps23881_class_table[ret]; } static int -- 2.43.0