Commit 3b141e8c authored by Stanley Chu's avatar Stanley Chu Committed by Martin K. Petersen

scsi: ufs: Avoid configuring regulator with undefined voltage range

For regulators used by UFS, vcc, vccq and vccq2 will have voltage range
initialized by ufshcd_populate_vreg(), however other regulators may have
undefined voltage range if dt-bindings have no such definition.

In above undefined case, both "min_uV" and "max_uV" fields in ufs_vreg
struct will be zero values and these values will be configured on
regulators in different power modes.

Currently this may have no harm if both "min_uV" and "max_uV" always keep
"zero values" because regulator_set_voltage() will always bypass such
invalid values and return "good" results.

However improper values shall be fixed to avoid potential bugs.  Simply
bypass voltage configuration if voltage range is not defined.
Signed-off-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Reviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
Acked-by: default avatarAlim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent e040362c
...@@ -7039,13 +7039,16 @@ static int ufshcd_config_vreg(struct device *dev, ...@@ -7039,13 +7039,16 @@ static int ufshcd_config_vreg(struct device *dev,
name = vreg->name; name = vreg->name;
if (regulator_count_voltages(reg) > 0) { if (regulator_count_voltages(reg) > 0) {
if (vreg->min_uV && vreg->max_uV) {
min_uV = on ? vreg->min_uV : 0; min_uV = on ? vreg->min_uV : 0;
ret = regulator_set_voltage(reg, min_uV, vreg->max_uV); ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
if (ret) { if (ret) {
dev_err(dev, "%s: %s set voltage failed, err=%d\n", dev_err(dev,
"%s: %s set voltage failed, err=%d\n",
__func__, name, ret); __func__, name, ret);
goto out; goto out;
} }
}
uA_load = on ? vreg->max_uA : 0; uA_load = on ? vreg->max_uA : 0;
ret = ufshcd_config_vreg_load(dev, vreg, uA_load); ret = ufshcd_config_vreg_load(dev, vreg, uA_load);
......
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