Netdev List
 help / color / mirror / Atom feed
From: Kory Maincent <kory.maincent@bootlin.com>
To: Kory Maincent <kory.maincent@bootlin.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: thomas.petazzoni@bootlin.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>
Subject: [PATCH net] net: pse-pd: tps23881: Fix reported power class
Date: Thu, 19 Nov 2026 12:25:07 +0100	[thread overview]
Message-ID: <20261119112511.239208-1-kory.maincent@bootlin.com> (raw)

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 <kory.maincent@bootlin.com>
---
 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


             reply	other threads:[~2026-11-19 11:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 11:25 Kory Maincent [this message]
2026-11-19 11:28 ` [PATCH net] net: pse-pd: tps23881: Fix reported power class netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119112511.239208-1-kory.maincent@bootlin.com \
    --to=kory.maincent@bootlin.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox