From 517c4c15630e07db6991d5944dd4e5182c7e43ef Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Thu, 12 Jul 2018 11:56:31 +0200 Subject: soc/cavium: Fix overflow before widen Fix Coverity CID1393974 Change-Id: I39caea8a248d2f1debfca307f6fb7a2fe3e431b1 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/27450 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- src/soc/cavium/cn81xx/gpio.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/soc/cavium/cn81xx') diff --git a/src/soc/cavium/cn81xx/gpio.c b/src/soc/cavium/cn81xx/gpio.c index 340ac1bc73..84e36d19fd 100644 --- a/src/soc/cavium/cn81xx/gpio.c +++ b/src/soc/cavium/cn81xx/gpio.c @@ -103,9 +103,9 @@ void gpio_set(gpio_t gpio, int value) printk(BIOS_SPEW, "GPIO(%u): level: %u\n", gpio, !!value); if (value) - write64(®s->tx_set, 1 << gpio); + write64(®s->tx_set, 1ULL << gpio); else - write64(®s->tx_clr, 1 << gpio); + write64(®s->tx_clr, 1ULL << gpio); } /* Set GPIO direction to OUTPUT with level */ @@ -153,9 +153,10 @@ int gpio_get(gpio_t gpio) return 0; const u64 reg = read64(®s->rx_dat); - printk(BIOS_SPEW, "GPIO(%u): input: %u\n", gpio, !!(reg & (1 << gpio))); + printk(BIOS_SPEW, "GPIO(%u): input: %u\n", gpio, + !!(reg & (1ULL << gpio))); - return !!(reg & (1 << gpio)); + return !!(reg & (1ULL << gpio)); } /* Read GPIO STRAP level sampled at cold boot */ @@ -167,9 +168,10 @@ int gpio_strap_value(gpio_t gpio) return 0; const u64 reg = read64(®s->strap); - printk(BIOS_SPEW, "GPIO(%u): strap: %u\n", gpio, !!(reg & (1 << gpio))); + printk(BIOS_SPEW, "GPIO(%u): strap: %u\n", gpio, + !!(reg & (1ULL << gpio))); - return !!(reg & (1 << gpio)); + return !!(reg & (1ULL << gpio)); } /* FIXME: Parse devicetree ? */ -- cgit v1.2.3