Skip to contentSkip to conversation

regulator: fix calculation of voltage range in da9034_set_ldo12_voltage()

PATCH Mark Brown 1 participant 1 message Aug 25, 2009 1 message not in the archive

lore
Share & tools
lore

Mark Brown

author
#1 lore raw
In reply to a message not in the archive
Quoted 3 lines · Roel Kluin

For val to be greater than 7 or less than 20 is logically always true.

Looks good to me but CCing in Eric and Mike just in case the intent of the code was something other than the new version.

Quoted 13 lines
drivers/regulator/da903x.c +1 -1
index b8b89ef..2d9bde5 100644
@@ -278,7 +278,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
 	}
 
 	val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
-	val = (val > 7 || val < 20) ? 8 : val - 12;
+	val = (val > 7 && val < 20) ? 8 : val - 12;
 	val <<= info->vol_shift;
 	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;