Skip to content

Commit 349c1b4

Browse files
Marius Cristeajic23
authored andcommitted
iio: adc: MCP3564: fix warn: unsigned '__x' is never less than zero.
The patch 33ec3e5: "iio: adc: adding support for MCP3564 ADC" 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: 33ec3e5 (iio: adc: adding support for MCP3564 ADC) Signed-off-by: Marius Cristea <marius.cristea@microchip.com> Link: https://lore.kernel.org/r/20231013132333.10582-1-marius.cristea@microchip.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent e16247a commit 349c1b4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iio/adc/mcp3564.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ static void mcp3564_fill_scale_tbls(struct mcp3564_state *adc)
11021102

11031103
for (i = 0; i < MCP3564_MAX_PGA; i++) {
11041104
ref = adc->vref_mv;
1105-
tmp1 = shift_right((u64)ref * NANO, pow);
1105+
tmp1 = ((u64)ref * NANO) >> pow;
11061106
div_u64_rem(tmp1, NANO, &tmp0);
11071107

11081108
tmp1 = tmp1 * mcp3564_hwgain_frac[(2 * i) + 1];

0 commit comments

Comments
 (0)