diff mbox series

power: supply: sc27xx: prevent adc * 1000 from overflow

Message ID 20200717053546.7981-1-zhang.lyra@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series power: supply: sc27xx: prevent adc * 1000 from overflow | expand

Commit Message

Chunyan Zhang July 17, 2020, 5:35 a.m. UTC
From: Chunyan Zhang <chunyan.zhang@unisoc.com>

The input parameter is int type, cause adc * 1000 could overflow.
Change to use s64 to avoid this issue.

Fixes: 195ca1703784 ("power: supply: Add Spreadtrum SC27XX fuel gauge unit driver")
Signed-off-by: Chen Yongzhi <yongzhi.chen@unisoc.com>
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
 drivers/power/supply/sc27xx_fuel_gauge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

kernel test robot July 17, 2020, 3:11 p.m. UTC | #1
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
Reported-by: kernel test robot <lkp@intel.com>

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@lists.01.org
diff mbox series

Patch

diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c
index be42e814ea34..a9838a2a673d 100644
--- a/drivers/power/supply/sc27xx_fuel_gauge.c
+++ b/drivers/power/supply/sc27xx_fuel_gauge.c
@@ -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);
 }