From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: "Ariana Lazar" <ariana.lazar@microchip.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [bug report] iio: dac: adding support for Microchip MCP47FEB02
Date: Fri, 6 Feb 2026 16:04:07 +0200 [thread overview]
Message-ID: <aYX016NlTNkJzGdT@smile.fi.intel.com> (raw)
In-Reply-To: <aYXvP5FLA5BvkoVX@stanley.mountain>
On Fri, Feb 06, 2026 at 04:40:15PM +0300, Dan Carpenter wrote:
> [ 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'
Btw, why the bot mangles the patch, please?
Adding leading information (line number and some other markings) should not
mangle the code (tab-based indentation).
> 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.
Why not? When it's negative I believe the above statement is not true.
> Return -EINVAL.
Probably true for the == 0 case.
With the above, this probably should be
> 734 if (data->use_vref1)
> 735 tmp_vref = vref1_mV;
> 736 else
> 737 tmp_vref = MCP47FEB02_INTERNAL_BAND_GAP_mV;
if (data->use_vref1) {
if (vref1_mV < 0)
return dev_err_probe(dev, vref1_mV, "Can't get voltage for Vref1\n");
if (vref1_mV == 0)
return dev_err_probe(dev, -ERANGE, "Invalid voltage for Vref1\n");
// or -EINVAL?
tmp_vref = vref1_mV;
} else {
tmp_vref = MCP47FEB02_INTERNAL_BAND_GAP_mV;
}
> 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 }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-02-06 14:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <caa37f28-a2e8-4e0a-a9ce-a365ce805e4b@stanley.mountain>
2026-02-06 13:40 ` [bug report] iio: dac: adding support for Microchip MCP47FEB02 Dan Carpenter
2026-02-06 14:04 ` Andy Shevchenko [this message]
2026-02-06 14:33 ` Dan Carpenter
2026-02-06 15:14 ` Andy Shevchenko
2026-02-06 15:32 ` Dan Carpenter
2026-02-06 15:57 ` Andy Shevchenko
2026-02-10 10:26 ` Ariana.Lazar
2026-03-01 12:31 ` Jonathan Cameron
2026-03-02 10:28 ` Ariana.Lazar
2026-03-03 21:41 ` Jonathan Cameron
2026-02-06 13:40 ` [bug report] iio: adc: Add support for ad4062 Dan Carpenter
2026-02-06 14:07 ` Andy Shevchenko
2026-03-01 12:34 ` Jonathan Cameron
2026-03-05 17:10 ` Jorge Marques
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aYX016NlTNkJzGdT@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=ariana.lazar@microchip.com \
--cc=dan.carpenter@linaro.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox