Commit 1b9419d1 authored by Juan Antonio Aldea-Armenteros's avatar Juan Antonio Aldea-Armenteros Committed by Greg Kroah-Hartman

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: default avatarJuan Antonio Aldea-Armenteros <juant.aldea@gmail.com>
Link: https://lore.kernel.org/r/20201119122737.189675-1-juant.aldea@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 41d02747
...@@ -161,7 +161,7 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, ...@@ -161,7 +161,7 @@ static int spmi_read_cmd(struct spmi_controller *ctrl,
SPMI_SLAVE_OFFSET * slave_id + SPMI_SLAVE_OFFSET * slave_id +
SPMI_APB_SPMI_RDATA0_BASE_ADDR + SPMI_APB_SPMI_RDATA0_BASE_ADDR +
i * SPMI_PER_DATAREG_BYTE); i * SPMI_PER_DATAREG_BYTE);
data = be32_to_cpu((__be32)data); data = be32_to_cpu((__be32 __force)data);
if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) { if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) {
memcpy(buf, &data, sizeof(data)); memcpy(buf, &data, sizeof(data));
buf += sizeof(data); buf += sizeof(data);
...@@ -236,7 +236,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, ...@@ -236,7 +236,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
buf += (bc % SPMI_PER_DATAREG_BYTE); buf += (bc % SPMI_PER_DATAREG_BYTE);
} }
writel((u32)cpu_to_be32(data), writel((u32 __force)cpu_to_be32(data),
spmi_controller->base + chnl_ofst + spmi_controller->base + chnl_ofst +
SPMI_APB_SPMI_WDATA0_BASE_ADDR + SPMI_APB_SPMI_WDATA0_BASE_ADDR +
SPMI_PER_DATAREG_BYTE * i); SPMI_PER_DATAREG_BYTE * i);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment