Skip to contentSkip to conversation

hwmon: (pmbus/mp2975) Eliminate dead code

PATCH New Guenter Roeck 2 participants 2 messages Jul 25 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (pmbus/mp2975) Eliminate dead code

Coverity reports dead code in mp2975_data2reg_linear11(). Code analysis shows that the parameter passed to the function is always non-negative. This means that negative values do not need to be handled, and the associated variable and conditional code can be removed.

No functional impact or change.

---
 drivers/hwmon/pmbus/mp2975.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/hwmon/pmbus/mp2975.c +0 -5
index 5393f7aeea0f..8e5193933ceb 100644
@@ -176,7 +176,6 @@ mp2975_vid2direct(int vrf, int val)
 static u16 mp2975_data2reg_linear11(s64 val)
 {
 	s16 exponent = 0, mantissa;
-	bool negative = false;
 
 	/* simple case */
 	if (val == 0)
@@ -196,10 +195,6 @@ static u16 mp2975_data2reg_linear11(s64 val)
 	/* Convert mantissa from milli-units to units */
 	mantissa = clamp_val(DIV_ROUND_CLOSEST_ULL(val, 1000), 0, 0x3ff);
 
-	/* restore sign */
-	if (negative)
-		mantissa = -mantissa;
-
 	/* Convert to 5 bit exponent, 11 bit mantissa */
 	return (mantissa & 0x7ff) | ((exponent << 11) & 0xf800);
 }
Signature · 1 line
2.45.2
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines

Coverity reports dead code in mp2975_data2reg_linear11(). Code analysis shows that the parameter passed to the function is always non-negative. This means that negative values do not need to be handled, and the associated variable and conditional code can be removed.

No functional impact or change.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1