On Tue, Jun 02, 2026 at 05:33:52PM +0100, Rodrigo Alencar via B4 Relay wrote:
>
> Get and enable regulators for vdd, vlogic and vref input power pins. Vdd
> is the input power supply, while vlogic powers the digital side. vref is
> replacing vcc, which is being deprecated, but still supported. The value
> of vref_mv is checked so that a device without internal voltage reference
> cannot proceed without an explicit supply. For correct operation, vdd and
> vlogic are required, then devm_regulator_get_enable() is used so the
> driver can still work without them by using the stub/dummy regulators.
> Error report uses dev_err_probe(), which helps debugging an init issue.
...
> + ret = devm_regulator_get_enable_read_voltage(dev, "vref");
> + if (ret == -ENODEV) /* vcc-supply is deprecated, but supported still */
> + ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
> if (ret < 0 && ret != -ENODEV)
It can be deduplicated now with
else if (ret < 0)
> - return ret;
> + return dev_err_probe(dev, ret, "failed to read vref voltage\n");
>
> st->use_internal_vref = ret == -ENODEV;
> st->vref_mv = st->use_internal_vref ? st->chip_info->int_vref_mv : ret
> / 1000;
>
Drop this blank line as the assignment and check are coupled.
> + if (!st->vref_mv)
> + return dev_err_probe(dev, -EINVAL,
> + "invalid or not provided vref voltage\n");
--
With Best Regards,
Andy Shevchenko