power: supply: sc27xx: prevent adc * 1000 from overflow
Subsystems (2)
Chunyan Zhang
reviewerPATCH 1/1 power: supply: sc27xx: prevent adc * 1000 from overflow
From: Chunyan Zhang <[email protected]>
The input parameter is int type, cause adc * 1000 could overflow. Change to use s64 to avoid this issue.
--- drivers/power/supply/sc27xx_fuel_gauge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/sc27xx_fuel_gauge.c +2 -2
@@ -133,12 +133,12 @@ static const char * const sc27xx_charger_supply_name[] = { "sc2723_charger", }; -static int sc27xx_fgu_adc_to_current (struct sc27xx_fgu_data *data,int adc) +static int sc27xx_fgu_adc_to_current (struct sc27xx_fgu_data *data,s64 adc) {return DIV_ROUND_CLOSEST (adc *1000 , data->cur_1000ma_adc); } -static int sc27xx_fgu_adc_to_voltage (struct sc27xx_fgu_data *data,int adc) +static int sc27xx_fgu_adc_to_voltage (struct sc27xx_fgu_data *data,s64 adc) {return DIV_ROUND_CLOSEST (adc *1000 , data->vol_1000mv_adc); }
Signature · 1 line
2.20.1
kernel test robot
build botI love your patch! Yet something to improve:
Hi Chunyan,
I love your patch! Yet something to improve:
[auto build test ERROR on power-supply/for-next]
[also build test ERROR on linux/master linus/master v5.8-rc5 next-20200716] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Chunyan-Zhang/power-supply-sc27xx-prevent-adc-1000-from-overflow/20200717-133835 base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next config: m68k-allyesconfig (attached as .config) compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
m68k-linux-ld: drivers/power/supply/sc27xx_fuel_gauge.o: in function `sc27xx_fgu_hw_init':
sc27xx_fuel_gauge.c:(.text+0x13ec): undefined reference to `__divdi3'
m68k-linux-ld: drivers/power/supply/sc27xx_fuel_gauge.o: in function `sc27xx_fgu_get_vbat_vol':
sc27xx_fuel_gauge.c:(.text+0x1d8): undefined reference to `__divdi3'
>> m68k-linux-ld: sc27xx_fuel_gauge.c:(.text+0x1f4): undefined reference to `__divdi3'
m68k-linux-ld: drivers/power/supply/sc27xx_fuel_gauge.o: in function `sc27xx_fgu_get_current':
sc27xx_fuel_gauge.c:(.text+0x2b8): undefined reference to `__divdi3'
m68k-linux-ld: sc27xx_fuel_gauge.c:(.text+0x2d4): undefined reference to `__divdi3'
m68k-linux-ld: drivers/power/supply/sc27xx_fuel_gauge.o:sc27xx_fuel_gauge.c:(.text+0x84e): more undefined references to `__divdi3' follow
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org