Re: [PATCH v3 1/2] hwmon: (max6639) : Update hwmon init using info structure

From: kernel test robot
Date: Mon Jun 03 2024 - 20:48:39 EST


Hi Naresh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 5fbf8734fb36cf67339f599f0e51747a6aff690c]

url: https://github.com/intel-lab-lkp/linux/commits/Naresh-Solanki/hwmon-max6639-Add-hwmon-attributes-for-fan-and-pwm/20240603-185014
base: 5fbf8734fb36cf67339f599f0e51747a6aff690c
patch link: https://lore.kernel.org/r/20240603103114.3263060-1-naresh.solanki%409elements.com
patch subject: [PATCH v3 1/2] hwmon: (max6639) : Update hwmon init using info structure
config: i386-randconfig-141-20240604 (https://download.01.org/0day-ci/archive/20240604/202406040851.agdur2M1-lkp@xxxxxxxxx/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0

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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406040851.agdur2M1-lkp@xxxxxxxxx/

New smatch warnings:
drivers/hwmon/max6639.c:227 max6639_read_fan() warn: unsigned 'res' is never less than zero.
drivers/hwmon/max6639.c:235 max6639_read_fan() error: uninitialized symbol 'val'.
drivers/hwmon/max6639.c:253 max6639_fan_is_visible() warn: signedness bug returning '(-4095)'
drivers/hwmon/max6639.c:278 max6639_read_pwm() warn: unsigned 'res' is never less than zero.

Old smatch warnings:
drivers/hwmon/max6639.c:233 max6639_read_fan() warn: unsigned 'res' is never less than zero.

vim +/res +227 drivers/hwmon/max6639.c

214
215 static int max6639_read_fan(struct device *dev, u32 attr, int channel,
216 long *fan_val)
217 {
218 struct max6639_data *data = dev_get_drvdata(dev);
219 unsigned int val, res;
220
221 if (IS_ERR(data))
222 return PTR_ERR(data);
223
224 switch (attr) {
225 case hwmon_fan_input:
226 res = regmap_read(data->regmap, MAX6639_REG_FAN_CNT(channel), &val);
> 227 if (res < 0)
228 return res;
229 *fan_val = FAN_FROM_REG(val, data->rpm_range[channel]);
230 return 0;
231 case hwmon_fan_fault:
232 res = max6639_get_status(dev, &val);
233 if (res < 0)
234 return res;
> 235 *fan_val = !!(val & BIT(1 - channel));
236 return 0;
237 default:
238 return -EOPNOTSUPP;
239 }
240 }
241
242 static int max6639_set_ppr(struct max6639_data *data, int channel, u8 ppr)
243 {
244 /* Decrement the PPR value and shift left by 6 to match the register format */
245 return regmap_write(data->regmap, MAX6639_REG_FAN_PPR(channel), ppr-- << 6);
246 }
247
248 static umode_t max6639_fan_is_visible(const void *_data, u32 attr, int channel)
249 {
250 struct max6639_data *data = (struct max6639_data *)_data;
251
252 if (IS_ERR(data))
> 253 return PTR_ERR(data);
254
255 switch (attr) {
256 case hwmon_fan_input:
257 case hwmon_fan_fault:
258 return 0444;
259 case hwmon_fan_pulses:
260 return 0644;
261 default:
262 return 0;
263 }
264 }
265
266 static int max6639_read_pwm(struct device *dev, u32 attr, int channel,
267 long *pwm_val)
268 {
269 struct max6639_data *data = dev_get_drvdata(dev);
270 unsigned int val, res;
271
272 if (IS_ERR(data))
273 return PTR_ERR(data);
274
275 switch (attr) {
276 case hwmon_pwm_input:
277 res = regmap_read(data->regmap, MAX6639_REG_TARGTDUTY(channel), &val);
> 278 if (res < 0)
279 return res;
280 *pwm_val = val * 255 / 120;
281 return 0;
282 default:
283 return -EOPNOTSUPP;
284 }
285 }
286

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki