regulator: ab8500: Optimize ab8540_aux3_regulator_get_voltage_sel

We can save a register read operation in some case if read
expand_register first.
If info->expand_register.voltage_mask bit is set, no need to read
voltage_reg.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Axel Lin 2013-04-10 14:46:20 +08:00 committed by Mark Brown
parent 375dc9c141
commit 241896ce8d
1 changed files with 21 additions and 27 deletions

View File

@ -521,7 +521,7 @@ static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
{
int ret, val;
int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
u8 regval, regval_expand;
@ -530,44 +530,38 @@ static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
return -EINVAL;
}
ret = abx500_get_register_interruptible(info->dev,
info->voltage_bank, info->voltage_reg, &regval);
if (ret < 0) {
dev_err(rdev_get_dev(rdev),
"couldn't read voltage reg for regulator\n");
return ret;
}
ret = abx500_get_register_interruptible(info->dev,
info->expand_register.voltage_bank,
info->expand_register.voltage_reg, &regval_expand);
if (ret < 0) {
dev_err(rdev_get_dev(rdev),
"couldn't read voltage reg for regulator\n");
"couldn't read voltage expand reg for regulator\n");
return ret;
}
dev_vdbg(rdev_get_dev(rdev),
"%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
" 0x%x\n",
info->desc.name, info->voltage_bank, info->voltage_reg,
info->voltage_mask, regval);
dev_vdbg(rdev_get_dev(rdev),
"%s-get_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
" 0x%x\n",
"%s-get_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
info->desc.name, info->expand_register.voltage_bank,
info->expand_register.voltage_reg,
info->expand_register.voltage_mask, regval_expand);
if (regval_expand&(info->expand_register.voltage_mask))
/* Vaux3 has a different layout */
val = info->expand_register.voltage_limit;
else
val = (regval & info->voltage_mask) >> info->voltage_shift;
if (regval_expand & info->expand_register.voltage_mask)
return info->expand_register.voltage_limit;
return val;
ret = abx500_get_register_interruptible(info->dev,
info->voltage_bank, info->voltage_reg, &regval);
if (ret < 0) {
dev_err(rdev_get_dev(rdev),
"couldn't read voltage reg for regulator\n");
return ret;
}
dev_vdbg(rdev_get_dev(rdev),
"%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
info->desc.name, info->voltage_bank, info->voltage_reg,
info->voltage_mask, regval);
return (regval & info->voltage_mask) >> info->voltage_shift;
}
static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,