From: Justin Chadwell Date: Wed, 3 Jul 2019 13:11:06 +0000 (+0100) Subject: Update renesas platform to not rely on undefined overflow behaviour X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=673406b50841ca45b3f041283a0d5f750611470e;p=project%2Fbcm63xx%2Fatf.git Update renesas platform to not rely on undefined overflow behaviour This consists of ensuring that the left operand of each shift is unsigned when the operation might overflow into the sign bit. Change-Id: I51278beacbe6da79853c3f0f0f94cd806fc9652c Signed-off-by: Justin Chadwell --- diff --git a/drivers/renesas/rcar/cpld/ulcb_cpld.c b/drivers/renesas/rcar/cpld/ulcb_cpld.c index 48308537..5ffb2e19 100644 --- a/drivers/renesas/rcar/cpld/ulcb_cpld.c +++ b/drivers/renesas/rcar/cpld/ulcb_cpld.c @@ -68,7 +68,7 @@ static void cpld_write(uint8_t addr, uint32_t data) for (i = 0; i < 32; i++) { /* MSB first */ - gpio_set_value(GPIO_OUTDT6, MOSI, data & (1 << 31)); + gpio_set_value(GPIO_OUTDT6, MOSI, data & (1U << 31)); gpio_set_value(GPIO_OUTDT6, SCLK, 1); data <<= 1; gpio_set_value(GPIO_OUTDT6, SCLK, 0); diff --git a/drivers/renesas/rcar/pwrc/pwrc.c b/drivers/renesas/rcar/pwrc/pwrc.c index d97e593b..f4c9d3ab 100644 --- a/drivers/renesas/rcar/pwrc/pwrc.c +++ b/drivers/renesas/rcar/pwrc/pwrc.c @@ -763,10 +763,10 @@ uint32_t rcar_pwrc_get_cluster(void) reg = mmio_read_32(RCAR_PRR); - if (reg & (1 << (STATE_CA53_CPU + RCAR_CA53CPU_NUM_MAX))) + if (reg & (1U << (STATE_CA53_CPU + RCAR_CA53CPU_NUM_MAX))) return RCAR_CLUSTER_CA57; - if (reg & (1 << (STATE_CA57_CPU + RCAR_CA57CPU_NUM_MAX))) + if (reg & (1U << (STATE_CA57_CPU + RCAR_CA57CPU_NUM_MAX))) return RCAR_CLUSTER_CA53; return RCAR_CLUSTER_A53A57; @@ -810,7 +810,7 @@ uint32_t rcar_pwrc_get_cpu_num(uint32_t c) count_ca57: if (IS_A53A57(c) || IS_CA57(c)) { - if (reg & (1 << (STATE_CA57_CPU + RCAR_CA57CPU_NUM_MAX))) + if (reg & (1U << (STATE_CA57_CPU + RCAR_CA57CPU_NUM_MAX))) goto done; for (i = 0; i < RCAR_CA57CPU_NUM_MAX; i++) { diff --git a/drivers/renesas/rcar/pwrc/pwrc.h b/drivers/renesas/rcar/pwrc/pwrc.h index cfb35ff9..e67c6ef2 100644 --- a/drivers/renesas/rcar/pwrc/pwrc.h +++ b/drivers/renesas/rcar/pwrc/pwrc.h @@ -15,7 +15,7 @@ #define PWKUPR_WEN (1ull << 31) -#define PSYSR_AFF_L2 (1 << 31) +#define PSYSR_AFF_L2 (1U << 31) #define PSYSR_AFF_L1 (1 << 30) #define PSYSR_AFF_L0 (1 << 29) #define PSYSR_WEN (1 << 28) diff --git a/plat/renesas/rcar/rcar_common.c b/plat/renesas/rcar/rcar_common.c index d24d71af..4ea753f2 100644 --- a/plat/renesas/rcar/rcar_common.c +++ b/plat/renesas/rcar/rcar_common.c @@ -18,10 +18,10 @@ #define MSTP318 (1 << 18) #define MSTP319 (1 << 19) #define PMSR 0x5c -#define PMSR_L1FAEG (1 << 31) +#define PMSR_L1FAEG (1U << 31) #define PMSR_PMEL1RX (1 << 23) #define PMCTLR 0x60 -#define PMSR_L1IATN (1 << 31) +#define PMSR_L1IATN (1U << 31) static int rcar_pcie_fixup(unsigned int controller) {