Skip to contentSkip to conversation

hwmon: (adm1031): Remove redundant assignment to variable range

PATCH Applied Colin Ian King 2 participants 2 messages Dec 4, 2021 – Dec 7, 2021

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

PATCH 1/1 hwmon: (adm1031): Remove redundant assignment to variable range

Variable range is being initialized with a value that is never read, it is being re-assigned in the next statement. The assignment is redundant, remove it and initialize range using the second assigned value. Clean up the formatting too by adding missing spaces.

---
 drivers/hwmon/adm1031.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwmon/adm1031.c +1 -2
index 257ec53ae723..ac841fa3a369 100644
@@ -242,9 +242,8 @@ static int FAN_TO_REG(int reg, int div)
 static int AUTO_TEMP_MAX_TO_REG(int val, int reg, int pwm)
 {
 	int ret;
-	int range = val - AUTO_TEMP_MIN_FROM_REG(reg);
+	int range = ((val - AUTO_TEMP_MIN_FROM_REG(reg)) * 10) / (16 - pwm);
 
-	range = ((val - AUTO_TEMP_MIN_FROM_REG(reg))*10)/(16 - pwm);
 	ret = ((reg & 0xf8) |
 	       (range < 10000 ? 0 :
 		range < 20000 ? 1 :
Signature · 1 line
2.33.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Colin Ian King

Variable range is being initialized with a value that is never read, it is being re-assigned in the next statement. The assignment is redundant, remove it and initialize range using the second assigned value. Clean up the formatting too by adding missing spaces.

Applied.

Thanks,
Guenter

Quoted 19 lines
---
 drivers/hwmon/adm1031.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwmon/adm1031.c +1 -2
index 257ec53ae723..ac841fa3a369 100644
@@ -242,9 +242,8 @@ static int FAN_TO_REG(int reg, int div)
 static int AUTO_TEMP_MAX_TO_REG(int val, int reg, int pwm)
 {
 	int ret;
-	int range = val - AUTO_TEMP_MIN_FROM_REG(reg);
+	int range = ((val - AUTO_TEMP_MIN_FROM_REG(reg)) * 10) / (16 - pwm);
 
-	range = ((val - AUTO_TEMP_MIN_FROM_REG(reg))*10)/(16 - pwm);
 	ret = ((reg & 0xf8) |
 	       (range < 10000 ? 0 :
 		range < 20000 ? 1 :