Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: lp872x: Kill _rdev_to_offset() function

There is only one user calling _rdev_to_offset() function.
Remove _rdev_to_offset() makes the code simpler.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Axel Lin and committed by
Mark Brown
2c129927 9489e9dc

+7 -29
+7 -29
drivers/regulator/lp872x.c
··· 181 181 return regmap_update_bits(lp->regmap, addr, mask, data); 182 182 } 183 183 184 - static int _rdev_to_offset(struct regulator_dev *rdev) 185 - { 186 - enum lp872x_regulator_id id = rdev_get_id(rdev); 187 - 188 - switch (id) { 189 - case LP8720_ID_LDO1 ... LP8720_ID_BUCK: 190 - return id; 191 - case LP8725_ID_LDO1 ... LP8725_ID_BUCK2: 192 - return id - LP8725_ID_BASE; 193 - default: 194 - return -EINVAL; 195 - } 196 - } 197 - 198 184 static int lp872x_get_timestep_usec(struct lp872x *lp) 199 185 { 200 186 enum lp872x_id chip = lp->chipid; ··· 220 234 static int lp872x_regulator_enable_time(struct regulator_dev *rdev) 221 235 { 222 236 struct lp872x *lp = rdev_get_drvdata(rdev); 223 - enum lp872x_regulator_id regulator = rdev_get_id(rdev); 237 + enum lp872x_regulator_id rid = rdev_get_id(rdev); 224 238 int time_step_us = lp872x_get_timestep_usec(lp); 225 - int ret, offset; 239 + int ret; 226 240 u8 addr, val; 227 241 228 242 if (time_step_us < 0) 229 243 return -EINVAL; 230 244 231 - switch (regulator) { 232 - case LP8720_ID_LDO1 ... LP8720_ID_LDO5: 233 - case LP8725_ID_LDO1 ... LP8725_ID_LILO2: 234 - offset = _rdev_to_offset(rdev); 235 - if (offset < 0) 236 - return -EINVAL; 237 - 238 - addr = LP872X_LDO1_VOUT + offset; 245 + switch (rid) { 246 + case LP8720_ID_LDO1 ... LP8720_ID_BUCK: 247 + addr = LP872X_LDO1_VOUT + rid; 239 248 break; 240 - case LP8720_ID_BUCK: 241 - addr = LP8720_BUCK_VOUT1; 242 - break; 243 - case LP8725_ID_BUCK1: 244 - addr = LP8725_BUCK1_VOUT1; 249 + case LP8725_ID_LDO1 ... LP8725_ID_BUCK1: 250 + addr = LP872X_LDO1_VOUT + rid - LP8725_ID_BASE; 245 251 break; 246 252 case LP8725_ID_BUCK2: 247 253 addr = LP8725_BUCK2_VOUT1;