[bug report] iio: dac: adding support for Microchip MCP47FEB02

Dan Carpenter
2026-02-06T13:40:20Z

[ Smatch checking is paused while we raise funding. #SadFace
https://lore.kernel.org/all/aTaiGSbWZ9DJaGo7@stanley.mountain/ -dan ]

Hello Ariana Lazar,

Commit bf394cc80369 ("iio: dac: adding support for Microchip
MCP47FEB02") from Dec 16, 2025 (linux-next), leads to the following
Smatch static checker warning:

drivers/iio/dac/mcp47feb02.c:732 mcp47feb02_init_scales_avail()
warn: passing zero to 'dev_err_probe'

drivers/iio/dac/mcp47feb02.c
712 static int mcp47feb02_init_scales_avail(struct mcp47feb02_data *data, int vdd_mV,
713 int vref_mV, int vref1_mV)
714 {
715 struct device *dev = regmap_get_device(data->regmap);
716 int tmp_vref;
717
718 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_VDD, vdd_mV, data->scale);
719
720 if (data->use_vref)
721 tmp_vref = vref_mV;
722 else
723 tmp_vref = MCP47FEB02_INTERNAL_BAND_GAP_mV;
724
725 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_GAIN_X1, tmp_vref, data->scale);
726 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_GAIN_X2, tmp_vref * 2, data->scale);
727
728 if (data->phys_channels >= 4) {
729 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_VDD, vdd_mV, data->scale_1);
730
731 if (data->use_vref1 && vref1_mV <= 0)
--> 732 return dev_err_probe(dev, vref1_mV, "Invalid voltage for Vref1\n");
^^^^^^^^
vref1_mV is not a valid error code. Return -EINVAL.

733
734 if (data->use_vref1)
735 tmp_vref = vref1_mV;
736 else
737 tmp_vref = MCP47FEB02_INTERNAL_BAND_GAP_mV;
738
739 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_GAIN_X1,
740 tmp_vref, data->scale_1);
741 mcp47feb02_init_scale(data, MCP47FEB02_SCALE_GAIN_X2,
742 tmp_vref * 2, data->scale_1);
743 }
744
745 return 0;
746 }

regards,
dan carpenter