diff options
author | Svyatoslav Ryhel <clamor95@gmail.com> | 2023-10-27 11:26:09 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-11-03 12:37:15 -0400 |
commit | 9b1d277471af2efc7974a6aede5b73f28b1d6287 (patch) | |
tree | 6387fbbc66e33496480e43553963855e1948c602 | |
parent | 8ab09b92dcac9f9ef0c78498f174ab87e9e286b0 (diff) | |
download | u-boot-9b1d277471af2efc7974a6aede5b73f28b1d6287.zip u-boot-9b1d277471af2efc7974a6aede5b73f28b1d6287.tar.gz u-boot-9b1d277471af2efc7974a6aede5b73f28b1d6287.tar.bz2 |
power: regulator: palmas: fix ldoln and ldousb detection
dev->driver_data will carry the tail of ldo if there is a number and
if there is no number it will be an error code, anyway it will not be
zero. This results in a wrong ldo regulator detection.
To avoid this check for non-numerical ldo first and then manipulate
dev->driver_data.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
-rw-r--r-- | drivers/power/regulator/palmas_regulator.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/power/regulator/palmas_regulator.c b/drivers/power/regulator/palmas_regulator.c index 3c4eb83..d615e94 100644 --- a/drivers/power/regulator/palmas_regulator.c +++ b/drivers/power/regulator/palmas_regulator.c @@ -301,19 +301,23 @@ static int palmas_ldo_probe(struct udevice *dev) uc_pdata->type = REGULATOR_TYPE_LDO; - if (dev->driver_data) { + /* check for ldoln and ldousb cases */ + if (!strcmp("ldoln", dev->name)) { + uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][9]; + uc_pdata->volt_reg = palmas_ldo_volt[type][9]; + return 0; + } + + if (!strcmp("ldousb", dev->name)) { + uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][10]; + uc_pdata->volt_reg = palmas_ldo_volt[type][10]; + return 0; + } + + if (dev->driver_data > 0) { u8 idx = dev->driver_data - 1; uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][idx]; uc_pdata->volt_reg = palmas_ldo_volt[type][idx]; - } else { - /* check for ldoln and ldousb cases */ - if (!strcmp("ldoln", dev->name)) { - uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][9]; - uc_pdata->volt_reg = palmas_ldo_volt[type][9]; - } else if (!strcmp("ldousb", dev->name)) { - uc_pdata->ctrl_reg = palmas_ldo_ctrl[type][10]; - uc_pdata->volt_reg = palmas_ldo_volt[type][10]; - } } return 0; |