[asahilinux:smc/work 9/18] include/linux/bits.h:35:29: warning: left shift count >= width of type

From: kernel test robot
Date: Mon Feb 07 2022 - 11:33:12 EST


tree: https://github.com/AsahiLinux/linux smc/work
head: 3dcf1f28dd3d0b36f11098cc61187986d00ee253
commit: 4dcb7038ce2579c3fe867685d0fdc3998958edc3 [9/18] platform/apple: Add new Apple Mac SMC driver
config: csky-allyesconfig (https://download.01.org/0day-ci/archive/20220208/202202080017.hd9ScSdU-lkp@xxxxxxxxx/config)
compiler: csky-linux-gcc (GCC) 11.2.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
# https://github.com/AsahiLinux/linux/commit/4dcb7038ce2579c3fe867685d0fdc3998958edc3
git remote add asahilinux https://github.com/AsahiLinux/linux
git fetch --no-tags asahilinux smc/work
git checkout 4dcb7038ce2579c3fe867685d0fdc3998958edc3
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=csky SHELL=/bin/bash drivers/clk/ drivers/dma/ drivers/platform/apple/ sound/soc/apple/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/platform/apple/smc_rtkit.c: In function 'apple_smc_cmd':
drivers/platform/apple/smc_rtkit.c:69:16: error: implicit declaration of function 'FIELD_PREP' [-Werror=implicit-function-declaration]
69 | msg = (FIELD_PREP(SMC_MSG, cmd) |
| ^~~~~~~~~~
In file included from include/linux/ratelimit_types.h:5,
from include/linux/ratelimit.h:5,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from drivers/platform/apple/smc_rtkit.c:8:
>> include/linux/bits.h:35:29: warning: left shift count >= width of type [-Wshift-count-overflow]
35 | (((~UL(0)) - (UL(1) << (l)) + 1) & \
| ^~
include/linux/bits.h:38:38: note: in expansion of macro '__GENMASK'
38 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~
drivers/platform/apple/smc_rtkit.c:29:41: note: in expansion of macro 'GENMASK'
29 | #define SMC_DATA GENMASK(63, 32)
| ^~~~~~~
drivers/platform/apple/smc_rtkit.c:73:27: note: in expansion of macro 'SMC_DATA'
73 | FIELD_PREP(SMC_DATA, arg));
| ^~~~~~~~
>> include/linux/bits.h:36:18: warning: right shift count is negative [-Wshift-count-negative]
36 | (~UL(0) >> (BITS_PER_LONG - 1 - (h))))
| ^~
include/linux/bits.h:38:38: note: in expansion of macro '__GENMASK'
38 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~
drivers/platform/apple/smc_rtkit.c:29:41: note: in expansion of macro 'GENMASK'
29 | #define SMC_DATA GENMASK(63, 32)
| ^~~~~~~
drivers/platform/apple/smc_rtkit.c:73:27: note: in expansion of macro 'SMC_DATA'
73 | FIELD_PREP(SMC_DATA, arg));
| ^~~~~~~~
drivers/platform/apple/smc_rtkit.c:85:13: error: implicit declaration of function 'FIELD_GET' [-Werror=implicit-function-declaration]
85 | if (FIELD_GET(SMC_ID, smc->cmd_ret) != smc->msg_id) {
| ^~~~~~~~~
In file included from include/linux/ratelimit_types.h:5,
from include/linux/ratelimit.h:5,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from drivers/platform/apple/smc_rtkit.c:8:
>> include/linux/bits.h:35:29: warning: left shift count >= width of type [-Wshift-count-overflow]
35 | (((~UL(0)) - (UL(1) << (l)) + 1) & \
| ^~
include/linux/bits.h:38:38: note: in expansion of macro '__GENMASK'
38 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~
drivers/platform/apple/smc_rtkit.c:29:41: note: in expansion of macro 'GENMASK'
29 | #define SMC_DATA GENMASK(63, 32)
| ^~~~~~~
drivers/platform/apple/smc_rtkit.c:96:39: note: in expansion of macro 'SMC_DATA'
96 | *ret_data = FIELD_GET(SMC_DATA, smc->cmd_ret);
| ^~~~~~~~
>> include/linux/bits.h:36:18: warning: right shift count is negative [-Wshift-count-negative]
36 | (~UL(0) >> (BITS_PER_LONG - 1 - (h))))
| ^~
include/linux/bits.h:38:38: note: in expansion of macro '__GENMASK'
38 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~
drivers/platform/apple/smc_rtkit.c:29:41: note: in expansion of macro 'GENMASK'
29 | #define SMC_DATA GENMASK(63, 32)
| ^~~~~~~
drivers/platform/apple/smc_rtkit.c:96:39: note: in expansion of macro 'SMC_DATA'
96 | *ret_data = FIELD_GET(SMC_DATA, smc->cmd_ret);
| ^~~~~~~~
cc1: some warnings being treated as errors


vim +35 include/linux/bits.h

295bcca84916cb5 Rikard Falkeborn 2020-04-06 33
295bcca84916cb5 Rikard Falkeborn 2020-04-06 34 #define __GENMASK(h, l) \
95b980d62d52c4c Masahiro Yamada 2019-07-16 @35 (((~UL(0)) - (UL(1) << (l)) + 1) & \
95b980d62d52c4c Masahiro Yamada 2019-07-16 @36 (~UL(0) >> (BITS_PER_LONG - 1 - (h))))
295bcca84916cb5 Rikard Falkeborn 2020-04-06 37 #define GENMASK(h, l) \
295bcca84916cb5 Rikard Falkeborn 2020-04-06 38 (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
8bd9cb51daac893 Will Deacon 2018-06-19 39

:::::: The code at line 35 was first introduced by commit
:::::: 95b980d62d52c4c1768ee719e8db3efe27ef52b2 linux/bits.h: make BIT(), GENMASK(), and friends available in assembly

:::::: TO: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx