Commit de784a7c authored by Andre Przywara's avatar Andre Przywara
Browse files

spi: Avoid signed shifts



Shifting signed types to the left is dodgy, especially by 31 bits, since
it depends on the result type whether the result is undefined or not.

Do not take any chances here, and mark those shift bases as unsigned where
we can or will hit bit 31, to avoid undefined behaviour.
Signed-off-by: default avatarAndre Przywara <osp@andrep.de>
parent 68140367
......@@ -94,7 +94,7 @@ void fel_writel(feldev_handle *dev, uint32_t addr, uint32_t val);
#define SUN4I_CTL_RF_RST (1 << 9)
#define SUN4I_CTL_XCH (1 << 10)
#define SUN6I_TCR_XCH (1 << 31)
#define SUN6I_TCR_XCH (1U << 31)
#define SUN4I_SPI0_CCTL (spi_base(dev) + 0x1C)
#define SUN4I_SPI0_CTL (spi_base(dev) + 0x08)
......@@ -271,10 +271,10 @@ static bool spi0_init(feldev_handle *dev)
if (spi_is_sun6i(dev)) {
/* Enable SPI in the master mode and do a soft reset */
reg_val = readl(SUN6I_SPI0_GCR);
reg_val |= (1 << 31) | 3;
reg_val |= (1U << 31) | 3;
writel(reg_val, SUN6I_SPI0_GCR);
/* Wait for completion */
while (readl(SUN6I_SPI0_GCR) & (1 << 31)) {}
while (readl(SUN6I_SPI0_GCR) & (1U << 31)) {}
} else {
reg_val = readl(SUN4I_SPI0_CTL);
reg_val |= SUN4I_CTL_MASTER;
......@@ -555,7 +555,7 @@ void aw_fel_spiflash_info(feldev_handle *dev)
}
printf("Manufacturer: %s (%02Xh), model: %02Xh, size: %d bytes.\n",
manufacturer, buf[3], buf[4], (1 << buf[5]));
manufacturer, buf[3], buf[4], (1U << buf[5]));
}
/*
......
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