Re: [PATCH v4] hwmon: (ads7828) Fix external VREF regulator handling

Guenter Roeck <[email protected]> Wed, 5 Aug 2026 07:52:33 -0700
Newsgroups org.kernel.vger.linux-hwmon,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Wed, Aug 05, 2026 at 02:16:45PM +0800, Qingshuang Fu wrote:
> From: Qingshuang Fu <[email protected]>
> 
> The driver currently has two issues with the external VREF regulator
> handling in ads7828_probe():
> 
> 1. All errors from devm_regulator_get_optional() are ignored, causing the
>    driver to incorrectly fall back to internal VREF even for transient
>    errors like -EPROBE_DEFER or genuine failures like -ENOMEM.
> 
> 2. The external regulator is never enabled. The driver calls
>    regulator_get_voltage() without first calling regulator_enable(),
>    so the VREF pin may remain unpowered if the regulator is not
>    configured as always-on.
> 
> Fix both issues by switching to devm_regulator_get_enable_read_voltage(),
> which handles regulator get, enable, and voltage read in one call.
> Only -ENODEV (no regulator specified in device tree) should trigger the
> fallback to internal VREF. All other errors are propagated to the caller.
> 
> Fixes: a8ddfea09566 ("hwmon: (ads7828) Accept optional parameters from device tree")
> Signed-off-by: Qingshuang Fu <[email protected]>

Applied.

Thanks,
Guenter