Skip to contentSkip to conversation

net: phy: marvell-88q2xxx: Fix clamped value in mv88q2xxx_hwmon_write

PATCH Applied Thorsten Blum 4 participants 4 messages Dec 2, 2025 – Dec 5, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: marvell-88q2xxx: Fix clamped value in mv88q2xxx_hwmon_write

The local variable 'val' was never clamped to -75000 or 180000 because the return value of clamp_val() was not used. Fix this by assigning the clamped value back to 'val', and use clamp() instead of clamp_val().

Fixes a557a92e6881 ("net: phy: marvell-88q2xxx: add support for temperature sensor")
---
 drivers/net/phy/marvell-88q2xxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/marvell-88q2xxx.c +1 -1
index f3d83b04c953..201dee1a1698 100644
@@ -698,7 +698,7 @@ static int mv88q2xxx_hwmon_write(struct device *dev,
 
 	switch (attr) {
 	case hwmon_temp_max:
-		clamp_val(val, -75000, 180000);
+		val = clamp(val, -75000, 180000);
 		val = (val / 1000) + 75;
 		val = FIELD_PREP(MDIO_MMD_PCS_MV_TEMP_SENSOR3_INT_THRESH_MASK,
 				 val);
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
Reviewed-by on v1 1/1
#1 lore raw

Hi Thorsten,

thanks for the fix.

Am Tue, Dec 02, 2025 at 06:27:44PM +0100 schrieb Thorsten Blum:

Quoted 28 lines

The local variable 'val' was never clamped to -75000 or 180000 because the return value of clamp_val() was not used. Fix this by assigning the clamped value back to 'val', and use clamp() instead of clamp_val().

Fixes a557a92e6881 ("net: phy: marvell-88q2xxx: add support for temperature sensor")
---
 drivers/net/phy/marvell-88q2xxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/marvell-88q2xxx.c +1 -1
index f3d83b04c953..201dee1a1698 100644
@@ -698,7 +698,7 @@ static int mv88q2xxx_hwmon_write(struct device *dev,
 
 	switch (attr) {
 	case hwmon_temp_max:
-		clamp_val(val, -75000, 180000);
+		val = clamp(val, -75000, 180000);
 		val = (val / 1000) + 75;
 		val = FIELD_PREP(MDIO_MMD_PCS_MV_TEMP_SENSOR3_INT_THRESH_MASK,
 				 val);
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Thorsten Blum
Quoted 7 lines · Thorsten Blum

The local variable 'val' was never clamped to -75000 or 180000 because the return value of clamp_val() was not used. Fix this by assigning the clamped value back to 'val', and use clamp() instead of clamp_val().

Fixes a557a92e6881 ("net: phy: marvell-88q2xxx: add support for temperature sensor")

Andrew

#3 lore raw
In reply to Thorsten Blum
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 2 Dec 2025 18:27:44 +0100 you wrote:

The local variable 'val' was never clamped to -75000 or 180000 because the return value of clamp_val() was not used. Fix this by assigning the clamped value back to 'val', and use clamp() instead of clamp_val().

Fixes a557a92e6881 ("net: phy: marvell-88q2xxx: add support for temperature sensor")

[...]

Here is the summary with links:
- [net] net: phy: marvell-88q2xxx: Fix clamped value in mv88q2xxx_hwmon_write

    https://git.kernel.org/netdev/net/c/c4cdf7376271

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html