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

Configure Feed

Select the types of activity you want to include in your feed.

staging: trivial: hikey9xx: fix be32<->u32 casting warnings

This patch fixes the following warnings reported by sparse, by adding
missing __force annotations.

drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32
drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32

drivers/staging/hikey9xx/hisi-spmi-controller.c:239:25: warning: cast from restricted __be32

Rationale for #164:
data is declared as u32, and it is read and then converted by means of
be32_to_cpu(). Said function expects a __be32 but data is u32, therefore
there's a type missmatch here.

Rationale for #239:
Is the dual of #164. This time data going to be written so it
needs to be converted from cpu to __be32, but writel() expects u32 and the
output of cpu_to_be32 returns a __be32.

Signed-off-by: Juan Antonio Aldea-Armenteros <juant.aldea@gmail.com>
Link: https://lore.kernel.org/r/20201119122737.189675-1-juant.aldea@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Juan Antonio Aldea-Armenteros and committed by
Greg Kroah-Hartman
1b9419d1 41d02747

+2 -2
+2 -2
drivers/staging/hikey9xx/hisi-spmi-controller.c
··· 161 161 SPMI_SLAVE_OFFSET * slave_id + 162 162 SPMI_APB_SPMI_RDATA0_BASE_ADDR + 163 163 i * SPMI_PER_DATAREG_BYTE); 164 - data = be32_to_cpu((__be32)data); 164 + data = be32_to_cpu((__be32 __force)data); 165 165 if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) { 166 166 memcpy(buf, &data, sizeof(data)); 167 167 buf += sizeof(data); ··· 236 236 buf += (bc % SPMI_PER_DATAREG_BYTE); 237 237 } 238 238 239 - writel((u32)cpu_to_be32(data), 239 + writel((u32 __force)cpu_to_be32(data), 240 240 spmi_controller->base + chnl_ofst + 241 241 SPMI_APB_SPMI_WDATA0_BASE_ADDR + 242 242 SPMI_PER_DATAREG_BYTE * i);