diff options
author | Tom Rini <trini@konsulko.com> | 2023-08-14 09:14:51 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-08-14 09:14:51 -0400 |
commit | 831a80c2af322a80890cd9ef81c8ab7697788712 (patch) | |
tree | 99340a83103530a83c49b59a9280cc833bd1bec3 /drivers/adc/adc-uclass.c | |
parent | 321d7b4d875a77552a969dd6ea5bbed2644fcb0c (diff) | |
parent | 01b2917a1973b804338d3edbbd46198c540ba9f5 (diff) |
Merge branch '2023-08-14-keep-fixed-gpio-regulator-count-in-balance' into next
To quote the author:
The commit 4fcba5d556b4 ("regulator: implement basic reference counter")
have made it more important to keep fixed/gpio regulators enable/disable
state in balance.
This series fixes an inbalance in the mmc_dw driver and changes to use
the more relaxed regulator_set_enable_if_allowed function for a few
other drivers.
The regulator_set_enable_if_allowed function is more relaxed and will
return ENOSYS if the provided regulator is NULL or when DM_REGULATOR
was disabled. Using the following call convention should be safe:
ret = regulator_set_enable_if_allowed(<supply>, <true|false>);
if (ret && ret != -ENOSYS)
return ret;
Diffstat (limited to 'drivers/adc/adc-uclass.c')
-rw-r--r-- | drivers/adc/adc-uclass.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c index 9646e4d7062..6074eccbf09 100644 --- a/drivers/adc/adc-uclass.c +++ b/drivers/adc/adc-uclass.c @@ -51,23 +51,21 @@ static int check_channel(struct udevice *dev, int value, bool number_or_mask, static int adc_supply_enable(struct udevice *dev) { struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); - const char *supply_type; - int ret = 0; + int ret; - if (uc_pdata->vdd_supply) { - supply_type = "vdd"; - ret = regulator_set_enable(uc_pdata->vdd_supply, true); + ret = regulator_set_enable_if_allowed(uc_pdata->vdd_supply, true); + if (ret && ret != -ENOSYS) { + pr_err("%s: can't enable vdd-supply!", dev->name); + return ret; } - if (!ret && uc_pdata->vss_supply) { - supply_type = "vss"; - ret = regulator_set_enable(uc_pdata->vss_supply, true); + ret = regulator_set_enable_if_allowed(uc_pdata->vss_supply, true); + if (ret && ret != -ENOSYS) { + pr_err("%s: can't enable vss-supply!", dev->name); + return ret; } - if (ret) - pr_err("%s: can't enable %s-supply!", dev->name, supply_type); - - return ret; + return 0; } int adc_data_mask(struct udevice *dev, unsigned int *data_mask) |