summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-npcm-pspi.c
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2018-11-17 06:55:04 +0300
committerMark Brown <broonie@kernel.org>2018-11-27 17:07:08 +0300
commit1d2319efb6a970d5f5740a60828244e6c309df2b (patch)
treeea1960e2103d9caa7279917c627b4b10cf6123ea /drivers/spi/spi-npcm-pspi.c
parenta1880d38674b1b7e120a231151298b2eb530b645 (diff)
downloadlinux-1d2319efb6a970d5f5740a60828244e6c309df2b.tar.xz
spi: npcm: Fix uninitialized variable warning
The compiler has no way to know that rsize 1 or 2 are the only valid values. Also simplify the code a bit with early return. The warning was: drivers/spi/spi-npcm-pspi.c:215:6: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized] Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-npcm-pspi.c')
-rw-r--r--drivers/spi/spi-npcm-pspi.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c
index fed05b02007c..dda91c19af93 100644
--- a/drivers/spi/spi-npcm-pspi.c
+++ b/drivers/spi/spi-npcm-pspi.c
@@ -217,15 +217,23 @@ static void npcm_pspi_recv(struct npcm_pspi *priv)
rsize = min(bytes_per_word(priv->bits_per_word), priv->rx_bytes);
priv->rx_bytes -= rsize;
- if (priv->rx_buf) {
- if (rsize == 1)
- val = ioread8(priv->base + NPCM_PSPI_DATA);
- if (rsize == 2)
- val = ioread16(priv->base + NPCM_PSPI_DATA);
+ if (!priv->rx_buf)
+ return;
- *priv->rx_buf = val;
- priv->rx_buf += rsize;
+ switch (rsize) {
+ case 1:
+ val = ioread8(priv->base + NPCM_PSPI_DATA);
+ break;
+ case 2:
+ val = ioread16(priv->base + NPCM_PSPI_DATA);
+ break;
+ default:
+ WARN_ON_ONCE(1);
+ return;
}
+
+ *priv->rx_buf = val;
+ priv->rx_buf += rsize;
}
static int npcm_pspi_transfer_one(struct spi_master *master,