Re: [PATCH v2] hwmon: (ads7828) Don't ignore errors from devm_regulator_get_optional()
[email protected] Wed, 05 Aug 2026 03:10:11 +0000
| Newsgroups | org.kernel.vger.linux-hwmon |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: Pre-existing issues: - [High] The driver acquires the external 'vref' regulator and reads its vo= ltage but never enables it. -- --- Patch [1]: [PATCH v2] hwmon: (ads7828) Don't ignore errors from devm_re= gulator_get_optional() --- commit 49f8d154ff184810c29b27c75b5602ac3ecd4f65 Author: Qingshuang Fu <[email protected]> Subject: hwmon: (ads7828) Don't ignore errors from devm_regulator_get_optio= nal() The driver currently ignores all errors from devm_regulator_get_optional() and falls back to using the internal VREF. This commit changes the driver to propagate genuine errors other than -ENODEV to the caller instead of silently ignoring them. > diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c > index 149cfcec78dcc..1c3a8ce8afb5b 100644 > --- a/drivers/hwmon/ads7828.c > +++ b/drivers/hwmon/ads7828.c > @@ -133,6 +133,8 @@ static int ads7828_probe(struct i2c_client *client) > vref_mv > ADS7828_EXT_VREF_MV_MAX) > return -EINVAL; > ext_vref =3D true; > + } else if (PTR_ERR(reg) !=3D -ENODEV) { > + return PTR_ERR(reg); > } [Severity: High] This is a pre-existing issue, but looking at ads7828_probe(), the driver acquires the external vref regulator and reads its voltage but never actual= ly enables it: reg =3D devm_regulator_get_optional(dev, "vref"); if (!IS_ERR(reg)) { vref_uv =3D regulator_get_voltage(reg); vref_mv =3D DIV_ROUND_CLOSEST(vref_uv, 1000); ... If the external vref regulator is not marked as regulator-always-on in the device tree, won't the regulator subsystem disable it during the late initc= all unused-regulator cleanup? Could this cut the reference voltage to the ADC and cause it to return zero= ed or completely incorrect sensor readings? Should the driver call regulator_enable() or perhaps use devm_regulator_get_enable_read_voltage() instead? > } > --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260805030056.1082= [email protected]?part=3D1