Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: mtk-pmic-wrap: avoid integer overflow warning

On ARM64, the mtk-pmic-wrap driver causes a harmless warning:

mtk-pmic-wrap.c:1062:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]
mtk-pmic-wrap.c:1074:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]
mtk-pmic-wrap.c:1086:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]
.int_en_all = ~(BIT(31) | BIT(1)),

The problem is that the result of the BIT() macro is an 'unsigned long',
so taking the bitwise NOT operation of that results in an integer
with the upper 32 bits all set and that cannot be assigned to a
'u32' variable without loss of information.

This is harmless because we were never interested in the upper bits
here anyway, so we can shut up the warning by adding a simple cast
to 'u32'.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+3 -3
+3 -3
drivers/soc/mediatek/mtk-pmic-wrap.c
··· 1059 1059 .regs = mt2701_regs, 1060 1060 .type = PWRAP_MT2701, 1061 1061 .arb_en_all = 0x3f, 1062 - .int_en_all = ~(BIT(31) | BIT(2)), 1062 + .int_en_all = ~(u32)(BIT(31) | BIT(2)), 1063 1063 .spi_w = PWRAP_MAN_CMD_SPI_WRITE_NEW, 1064 1064 .wdt_src = PWRAP_WDT_SRC_MASK_ALL, 1065 1065 .has_bridge = 0, ··· 1071 1071 .regs = mt8135_regs, 1072 1072 .type = PWRAP_MT8135, 1073 1073 .arb_en_all = 0x1ff, 1074 - .int_en_all = ~(BIT(31) | BIT(1)), 1074 + .int_en_all = ~(u32)(BIT(31) | BIT(1)), 1075 1075 .spi_w = PWRAP_MAN_CMD_SPI_WRITE, 1076 1076 .wdt_src = PWRAP_WDT_SRC_MASK_ALL, 1077 1077 .has_bridge = 1, ··· 1083 1083 .regs = mt8173_regs, 1084 1084 .type = PWRAP_MT8173, 1085 1085 .arb_en_all = 0x3f, 1086 - .int_en_all = ~(BIT(31) | BIT(1)), 1086 + .int_en_all = ~(u32)(BIT(31) | BIT(1)), 1087 1087 .spi_w = PWRAP_MAN_CMD_SPI_WRITE, 1088 1088 .wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD, 1089 1089 .has_bridge = 0,