Commit df33799c authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

regulator: s2mps11: Reduce number of rdev_get_id() calls

Store the regulator ID instead of calling rdev_get_id() every time.
This makes code slightly easier to read as shorter 'rdev_id' variable is
used instead of full call.  This can also speed things up by reducing
number of calls, although effect was not measured.
Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent b01d1823
...@@ -70,10 +70,11 @@ static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev, ...@@ -70,10 +70,11 @@ static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
unsigned int new_selector) unsigned int new_selector)
{ {
struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev); struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
int rdev_id = rdev_get_id(rdev);
unsigned int ramp_delay = 0; unsigned int ramp_delay = 0;
int old_volt, new_volt; int old_volt, new_volt;
switch (rdev_get_id(rdev)) { switch (rdev_id) {
case S2MPS11_BUCK2: case S2MPS11_BUCK2:
ramp_delay = s2mps11->ramp_delay2; ramp_delay = s2mps11->ramp_delay2;
break; break;
...@@ -111,9 +112,10 @@ static int s2mps11_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) ...@@ -111,9 +112,10 @@ static int s2mps11_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev); struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
unsigned int ramp_val, ramp_shift, ramp_reg = S2MPS11_REG_RAMP_BUCK; unsigned int ramp_val, ramp_shift, ramp_reg = S2MPS11_REG_RAMP_BUCK;
unsigned int ramp_enable = 1, enable_shift = 0; unsigned int ramp_enable = 1, enable_shift = 0;
int rdev_id = rdev_get_id(rdev);
int ret; int ret;
switch (rdev_get_id(rdev)) { switch (rdev_id) {
case S2MPS11_BUCK1: case S2MPS11_BUCK1:
if (ramp_delay > s2mps11->ramp_delay16) if (ramp_delay > s2mps11->ramp_delay16)
s2mps11->ramp_delay16 = ramp_delay; s2mps11->ramp_delay16 = ramp_delay;
...@@ -203,9 +205,8 @@ static int s2mps11_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) ...@@ -203,9 +205,8 @@ static int s2mps11_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
goto ramp_disable; goto ramp_disable;
/* Ramp delay can be enabled/disabled only for buck[2346] */ /* Ramp delay can be enabled/disabled only for buck[2346] */
if ((rdev_get_id(rdev) >= S2MPS11_BUCK2 && if ((rdev_id >= S2MPS11_BUCK2 && rdev_id <= S2MPS11_BUCK4) ||
rdev_get_id(rdev) <= S2MPS11_BUCK4) || rdev_id == S2MPS11_BUCK6) {
rdev_get_id(rdev) == S2MPS11_BUCK6) {
ret = regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP, ret = regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP,
1 << enable_shift, 1 << enable_shift); 1 << enable_shift, 1 << enable_shift);
if (ret) { if (ret) {
...@@ -503,20 +504,21 @@ static const struct regulator_desc s2mps13_regulators[] = { ...@@ -503,20 +504,21 @@ static const struct regulator_desc s2mps13_regulators[] = {
static int s2mps14_regulator_enable(struct regulator_dev *rdev) static int s2mps14_regulator_enable(struct regulator_dev *rdev)
{ {
struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev); struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
int rdev_id = rdev_get_id(rdev);
unsigned int val; unsigned int val;
switch (s2mps11->dev_type) { switch (s2mps11->dev_type) {
case S2MPS13X: case S2MPS13X:
case S2MPS14X: case S2MPS14X:
if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) if (test_bit(rdev_id, s2mps11->suspend_state))
val = S2MPS14_ENABLE_SUSPEND; val = S2MPS14_ENABLE_SUSPEND;
else if (s2mps11->ext_control_gpiod[rdev_get_id(rdev)]) else if (s2mps11->ext_control_gpiod[rdev_id])
val = S2MPS14_ENABLE_EXT_CONTROL; val = S2MPS14_ENABLE_EXT_CONTROL;
else else
val = rdev->desc->enable_mask; val = rdev->desc->enable_mask;
break; break;
case S2MPU02: case S2MPU02:
if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) if (test_bit(rdev_id, s2mps11->suspend_state))
val = S2MPU02_ENABLE_SUSPEND; val = S2MPU02_ENABLE_SUSPEND;
else else
val = rdev->desc->enable_mask; val = rdev->desc->enable_mask;
...@@ -570,7 +572,7 @@ static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev) ...@@ -570,7 +572,7 @@ static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev)
if (ret < 0) if (ret < 0)
return ret; return ret;
set_bit(rdev_get_id(rdev), s2mps11->suspend_state); set_bit(rdev_id, s2mps11->suspend_state);
/* /*
* Don't enable suspend mode if regulator is already disabled because * Don't enable suspend mode if regulator is already disabled because
* this would effectively for a short time turn on the regulator after * this would effectively for a short time turn on the regulator after
...@@ -856,8 +858,9 @@ static int s2mps11_pmic_dt_parse(struct platform_device *pdev, ...@@ -856,8 +858,9 @@ static int s2mps11_pmic_dt_parse(struct platform_device *pdev,
static int s2mpu02_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) static int s2mpu02_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
{ {
unsigned int ramp_val, ramp_shift, ramp_reg; unsigned int ramp_val, ramp_shift, ramp_reg;
int rdev_id = rdev_get_id(rdev);
switch (rdev_get_id(rdev)) { switch (rdev_id) {
case S2MPU02_BUCK1: case S2MPU02_BUCK1:
ramp_shift = S2MPU02_BUCK1_RAMP_SHIFT; ramp_shift = S2MPU02_BUCK1_RAMP_SHIFT;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment