diff options
author | Colin Ian King <colin.king@canonical.com> | 2017-06-22 12:34:49 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-06-23 07:26:38 -0400 |
commit | a2f07d38d6981ed220d86b7df07e4ac6a1734443 (patch) | |
tree | 2018ad9bac2d4fccb138c3547ee98dbaf2cec65c | |
parent | dcbe0d84dfa5a3e72b8e6ce622cd5ac78abbcab8 (diff) |
spi: stm32: fix error check on mbr being -ve
The error check of mbr < 0 is always false because mbr is a u32. Make
mbt an int so that a -ve error return from stm32_spi_prepare_mbr can be
detected.
Detected by CoverityScan, CID#1446586 ("Unsigned compared against 0")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-stm32.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 0553f61ab3b7..305ecd5334fc 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c | |||
@@ -857,7 +857,7 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi, | |||
857 | } | 857 | } |
858 | 858 | ||
859 | if (spi->cur_speed != transfer->speed_hz) { | 859 | if (spi->cur_speed != transfer->speed_hz) { |
860 | u32 mbr; | 860 | int mbr; |
861 | 861 | ||
862 | /* Update spi->cur_speed with real clock speed */ | 862 | /* Update spi->cur_speed with real clock speed */ |
863 | mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz); | 863 | mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz); |
@@ -869,7 +869,7 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi, | |||
869 | transfer->speed_hz = spi->cur_speed; | 869 | transfer->speed_hz = spi->cur_speed; |
870 | 870 | ||
871 | cfg1_clrb |= SPI_CFG1_MBR; | 871 | cfg1_clrb |= SPI_CFG1_MBR; |
872 | cfg1_setb |= (mbr << SPI_CFG1_MBR_SHIFT) & SPI_CFG1_MBR; | 872 | cfg1_setb |= ((u32)mbr << SPI_CFG1_MBR_SHIFT) & SPI_CFG1_MBR; |
873 | } | 873 | } |
874 | 874 | ||
875 | if (cfg1_clrb || cfg1_setb) | 875 | if (cfg1_clrb || cfg1_setb) |