Commit 6e56a6d4 authored by Kory Maincent's avatar Kory Maincent Committed by Paolo Abeni
Browse files

net: pse-pd: Add power limit check



Checking only the current limit is not sufficient. According to the
standard, voltage can reach up to 57V and current up to 1.92A, which
exceeds the power limit described in the standard (99.9W). Add a power
limit check to prevent this.

Acked-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: default avatarKory Maincent <kory.maincent@bootlin.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 675d0e3c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -877,6 +877,9 @@ int pse_ethtool_set_pw_limit(struct pse_control *psec,
	int uV, uA, ret;
	s64 tmp_64;

	if (pw_limit > MAX_PI_PW)
		return -ERANGE;

	ret = regulator_get_voltage(psec->ps);
	if (!ret) {
		NL_SET_ERR_MSG(extack,
+2 −0
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@

/* Maximum current in uA according to IEEE 802.3-2022 Table 145-1 */
#define MAX_PI_CURRENT 1920000
/* Maximum power in mW according to IEEE 802.3-2022 Table 145-16 */
#define MAX_PI_PW 99900

struct phy_device;
struct pse_controller_dev;