build warning in power: supply: Qualcomm PMIC GLINK power supply

From: Randy Dunlap
Date: Sun Feb 19 2023 - 13:38:34 EST


Hi Bjorn,

FYI: (seen in passing, I wasn't looking for this.)

When doing compile tests on MIPS (32-bit):

In file included from ../arch/mips/include/asm/div64.h:89,
from ../include/linux/math.h:6,
from ../include/linux/math64.h:6,
from ../include/linux/time64.h:5,
from ../include/linux/restart_block.h:10,
from ../include/linux/thread_info.h:14,
from ../include/asm-generic/current.h:5,
from ./arch/mips/include/generated/asm/current.h:1,
from ../include/linux/sched.h:12,
from ../include/linux/ratelimit.h:6,
from ../include/linux/dev_printk.h:16,
from ../include/linux/device.h:15,
from ../include/linux/auxiliary_bus.h:11,
from ../drivers/power/supply/qcom_battmgr.c:6:
../drivers/power/supply/qcom_battmgr.c: In function 'qcom_battmgr_sm8350_callback':
../include/asm-generic/div64.h:222:35: warning: comparison of distinct pointer types lacks a cast
222 | (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
| ^~
../drivers/power/supply/qcom_battmgr.c:1130:25: note: in expansion of macro 'do_div'
1130 | do_div(battmgr->status.percent, 100);
| ^~~~~~
In file included from ../include/linux/dev_printk.h:14:
../include/asm-generic/div64.h:234:32: warning: right shift count >= width of type [-Wshift-count-overflow]
234 | } else if (likely(((n) >> 32) == 0)) { \
| ^~
../include/linux/compiler.h:77:45: note: in definition of macro 'likely'
77 | # define likely(x) __builtin_expect(!!(x), 1)
| ^
../drivers/power/supply/qcom_battmgr.c:1130:25: note: in expansion of macro 'do_div'
1130 | do_div(battmgr->status.percent, 100);
| ^~~~~~


The first argument must be 64-bit. qcom_battmgr_status.percent is 'unsigned int',
which is not 64-bit (AFAIK; and according to LDD3).

--
~Randy