soc/cavium: Fix overflow before widen

Fix Coverity CID1393974

Change-Id: I39caea8a248d2f1debfca307f6fb7a2fe3e431b1
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/27450
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Patrick Rudolph 2018-07-12 11:56:31 +02:00 committed by Patrick Rudolph
parent cff16b6f9d
commit 517c4c1563
1 changed files with 8 additions and 6 deletions

View File

@ -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(&regs->tx_set, 1 << gpio);
write64(&regs->tx_set, 1ULL << gpio);
else
write64(&regs->tx_clr, 1 << gpio);
write64(&regs->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(&regs->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(&regs->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 ? */