[PATCH] regulator: preserve error code properly in regulator_list_autoset()
Simon Glass
sjg at chromium.org
Wed Aug 9 04:03:52 CEST 2023
Hi,
On Tue, 8 Aug 2023 at 15:42, Tom Rini <trini at konsulko.com> wrote:
>
> On Wed, Jul 26, 2023 at 10:01:21AM +0300, Dan Carpenter wrote:
>
> > This code has a & vs && typo so it only preserves odd value error
> > codes and not even value error codes.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>
> > Reviewed-by: Simon Glass <sjg at chromium.org>
> > ---
> > drivers/power/regulator/regulator-uclass.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
> > index 3a6ba69f6d5f..52dd1bd3eafd 100644
> > --- a/drivers/power/regulator/regulator-uclass.c
> > +++ b/drivers/power/regulator/regulator-uclass.c
> > @@ -380,7 +380,7 @@ int regulator_list_autoset(const char *list_platname[],
> > ret = regulator_autoset_by_name(list_platname[i], &dev);
> > if (ret != -EMEDIUMTYPE && verbose)
> > regulator_show(dev, ret);
> > - if (ret & !error)
> > + if (ret && !error)
> > error = ret;
> >
> > if (list_devp)
>
> This then leads to the test power_regulator_autoset_list in
> test/dm/regulator.c failing. Simon, please take a look, thanks.
The failure is:
test/dm/regulator.c:379, dm_test_power_regulator_autoset_list(): 0 ==
regulator_list_autoset(platname_list, dev_list, 0): Expected 0x0 (0),
got 0xffffff84 (-124)
This looks to be regulator_autoset() returning -EMEDIUMTYPE because:
(!uc_pdata->always_on && !uc_pdata->boot_on)
You apparently cannot autoset a regulator unless it has one of those
enabled. Just adding:
regulator-boot-on;
to LTO2 in arch/sandbox/dts/sandbox_pmic.dtsi
does not fix it:
test/dm/regulator.c:390, dm_test_power_regulator_autoset_list():
regulator_get_value(dev_list[i]) == expected_setting_list[i].voltage:
Expected 0x325aa0 (3300000), got 0x2dc6c0 (3000000)
So I suspect this is a real bug and the tests are checking for the bug.
+Jaehoon Chung (power maintainer)
Regards,
Simon
More information about the U-Boot
mailing list