linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] iio: adc: MCP3564: fix warn: unsigned '__x' is never less than zero.
@ 2023-10-02 16:16 marius.cristea
  2023-10-10  9:44 ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: marius.cristea @ 2023-10-02 16:16 UTC (permalink / raw)
  To: jic23, lars, lgirdwood, broonie; +Cc: linux-iio, linux-kernel, marius.cristea

From: Marius Cristea <marius.cristea@microchip.com>

The patch efea15e3c65d: "iio: adc: MCP3564: fix the static checker warning"
leads to the following Smatch static checker warning:

   smatch warnings:
   drivers/iio/adc/mcp3564.c:1105 mcp3564_fill_scale_tbls() warn: unsigned '__x' is never less than zero.

vim +/__x +1105 drivers/iio/adc/mcp3564.c

   1094
   1095  static void mcp3564_fill_scale_tbls(struct mcp3564_state *adc)
   1096  {
   .....
   1103          for (i = 0; i < MCP3564_MAX_PGA; i++) {
   1104                  ref = adc->vref_mv;
 > 1105                  tmp1 = shift_right((u64)ref * NANO, pow);
   1106                  div_u64_rem(tmp1, NANO, &tmp0);
   1107
   .....
   1113  }

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202309280738.NWjVfVt4-lkp@intel.com/
Fixes: efea15e3c65d (iio: adc: MCP3564: fix the static checker warning)
Signed-off-by: Marius Cristea <marius.cristea@microchip.com>
---
 drivers/iio/adc/mcp3564.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
index 9ede1a5d5d7b..e3f1de5fcc5a 100644
--- a/drivers/iio/adc/mcp3564.c
+++ b/drivers/iio/adc/mcp3564.c
@@ -1102,7 +1102,7 @@ static void mcp3564_fill_scale_tbls(struct mcp3564_state *adc)
 
 	for (i = 0; i < MCP3564_MAX_PGA; i++) {
 		ref = adc->vref_mv;
-		tmp1 = shift_right((u64)ref * NANO, pow);
+		tmp1 = ((u64)ref * NANO) >> pow;
 		div_u64_rem(tmp1, NANO, &tmp0);
 
 		tmp1 = tmp1 * mcp3564_hwgain_frac[(2 * i) + 1];

base-commit: 5e99f692d4e32e3250ab18d511894ca797407aec
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-12  8:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-02 16:16 [PATCH v1] iio: adc: MCP3564: fix warn: unsigned '__x' is never less than zero marius.cristea
2023-10-10  9:44 ` Jonathan Cameron
2023-10-11 16:41   ` Marius.Cristea
2023-10-12  7:36     ` Jonathan Cameron
2023-10-12  8:18       ` Marius.Cristea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).