]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
power: regulator: palmas: fix ldoln and ldousb detection
authorSvyatoslav Ryhel <clamor95@gmail.com>
Fri, 27 Oct 2023 08:26:09 +0000 (11:26 +0300)
committerTom Rini <trini@konsulko.com>
Fri, 3 Nov 2023 16:37:15 +0000 (12:37 -0400)
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>
drivers/power/regulator/palmas_regulator.c

index 3c4eb83be7744381a3e2f7450085c7cf6dfe7c80..d615e9473403e4dc82b87666a7e947f9b2e20dee 100644 (file)
@@ -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;