Re: [PATCH v5 02/11] iio: adc: Add basic support for AD4170
From: Andy Shevchenko
Date: Wed Jun 18 2025 - 14:01:27 EST
On Wed, Jun 18, 2025 at 08:37:53PM +0300, Dan Carpenter wrote:
> Hi Marcelo,
>
> kernel test robot noticed the following build warnings:
>
> url: https://github.com/intel-lab-lkp/linux/commits/Marcelo-Schmitt/dt-bindings-iio-adc-Add-AD4170/20250611-101842
> base: 4c6073fec2fee4827fa0dd8a4ab4e6f7bbc05ee6
> patch link: https://lore.kernel.org/r/48598c0753cccf515addbe85acba3f883ff8f036.1749582679.git.marcelo.schmitt%40analog.com
> patch subject: [PATCH v5 02/11] iio: adc: Add basic support for AD4170
> config: powerpc-randconfig-r072-20250613 (https://download.01.org/0day-ci/archive/20250614/202506140009.GdV0BtKr-lkp@xxxxxxxxx/config)
> compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project f819f46284f2a79790038e1f6649172789734ae8)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202506140009.GdV0BtKr-lkp@xxxxxxxxx/
>
> smatch warnings:
> drivers/iio/adc/ad4170.c:1181 ad4170_parse_adc_channel_type() warn: passing zero to 'dev_err_probe'
>
> vim +/dev_err_probe +1181 drivers/iio/adc/ad4170.c
>
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1170 static int ad4170_parse_adc_channel_type(struct device *dev,
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1171 struct fwnode_handle *child,
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1172 struct iio_chan_spec *chan)
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1173 {
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1174 int ret, ret2;
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1175 u32 pins[2];
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1176
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1177 /* Parse pseudo-differential channel configuration */
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1178 ret = fwnode_property_read_u32(child, "single-channel", &pins[0]);
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1179 ret2 = fwnode_property_read_u32(child, "common-mode-channel", &pins[1]);
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1180 if (!ret && ret2)
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 @1181 return dev_err_probe(dev, ret,
> ^^^
> ret is zero, so this returns success. s/ret/ret2/.
>
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1182 "single-ended channels must define common-mode-channel\n");
Instead of ret and ret2 this code should be refactored to use
_preperty_present() beforehands and return an error to the caller if it's
present but failed to be read or not optional at all.
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1184 if (!ret && !ret2) {
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1185 chan->differential = false;
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1186 chan->channel = pins[0];
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1187 chan->channel2 = pins[1];
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1188 return 0;
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1189 }
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1190 /* Failed to parse pseudo-diff chan props so try diff chan */
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1191
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1192 /* Parse differential channel configuration */
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1193 ret = fwnode_property_read_u32_array(child, "diff-channels", pins,
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1194 ARRAY_SIZE(pins));
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1195 if (!ret) {
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1196 chan->differential = true;
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1197 chan->channel = pins[0];
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1198 chan->channel2 = pins[1];
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1199 return 0;
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1200 }
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1201 return dev_err_probe(dev, ret,
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1202 "Channel must define one of diff-channels or single-channel.\n");
> dfefd2b2405829 Ana-Maria Cusco 2025-06-10 1203 }
--
With Best Regards,
Andy Shevchenko