regulator: max8973: make default/unset dvs gpio as invalid gpio
PATCH RESEND 1/2 regulator: max8973: make default/unset dvs gpio as invalid gpio
If platform data has dvs-gpio value 0 as default/unset then make this as invalid gpio so that function gpio_is_valid() can return false on this case.
---
This patch is applied earlier but not able to apply on latest so sending it again.
drivers/regulator/max8973-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/max8973-regulator.c +1 -1
@@ -413,7 +413,7 @@ static int max8973_probe(struct i2c_client *client, }if (pdata) { - max->dvs_gpio = pdata->dvs_gpio; + max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL ; max->enable_external_control = pdata->enable_ext_control; max->curr_gpio_val = pdata->dvs_def_state; max->curr_vout_reg =MAX8973_VOUT + pdata->dvs_def_state;
Signature · 1 line
2.1.4
PATCH RESEND 2/2 regulator: max8973: get rid of extra variable for gpio validity
To find that dvs-gpio is valid or not, gpio API gpio_is_valid() can be directly used instead of intermediate variable.
Removing the extra variable and using the gpio_is_valid().
---
This patch is applied earlier but not able to apply on latest so sending it again.
drivers/regulator/max8973-regulator.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/regulator/max8973-regulator.c +2 -6
@@ -100,7 +100,6 @@ struct max8973_chip {int curr_vout_val[MAX8973_MAX_VOUT_REG ];int curr_vout_reg;int curr_gpio_val; -bool valid_dvs_gpio;struct regulator_ops ops; };
@@ -174,7 +173,7 @@ static int max8973_dcdc_set_voltage_sel(struct regulator_dev *rdev,* If gpios are available to select the VOUT register then least * recently used register for new configuration. */ -if (max->valid_dvs_gpio) +if (gpio_is_valid (max->dvs_gpio)) found =find_voltage_set_register (max, vsel, &vout_reg, &gpio_val);
@@ -191,7 +190,7 @@ static int max8973_dcdc_set_voltage_sel(struct regulator_dev *rdev, }/* Select proper VOUT register vio gpios */ -if (max->valid_dvs_gpio) { +if (gpio_is_valid (max->dvs_gpio)) {gpio_set_value_cansleep (max->dvs_gpio, gpio_val &0x1 ); max->curr_gpio_val = gpio_val; }
@@ -438,7 +437,6 @@ static int max8973_probe(struct i2c_client *client, max->dvs_gpio, ret);return ret; } - max->valid_dvs_gpio = true;/* * Initialize the lru index with vout_reg id
@@ -448,8 +446,6 @@ static int max8973_probe(struct i2c_client *client, max->lru_index[i] = i; max->lru_index[0 ] = max->curr_vout_reg; max->lru_index[max->curr_vout_reg] =0 ; - }else { - max->valid_dvs_gpio = false; }if (pdata) {
Signature · 1 line
2.1.4
Re: [RESEND PATCH 2/2] regulator: max8973: get rid of extra variable for gpio validity
Quoted 2 lines · Laxman Dewangan
To find that dvs-gpio is valid or not, gpio API
gpio_is_valid()can be directly used instead of intermediate variable.
Applied, thanks. Hopefully nobody's using zero as default for pdata...
Quoted 3 lines · Laxman Dewangan
If platform data has dvs-gpio value 0 as default/unset then make this as invalid gpio so that function
gpio_is_valid()can return false on this case.
Applied, thanks.