Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 1d2319ef authored by Olof Johansson's avatar Olof Johansson Committed by Mark Brown
Browse files

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: default avatarOlof Johansson <olof@lixom.net>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent a1880d38
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -217,16 +217,24 @@ 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)
	if (!priv->rx_buf)
		return;

	switch (rsize) {
	case 1:
		val = ioread8(priv->base + NPCM_PSPI_DATA);
		if (rsize == 2)
		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,
				  struct spi_device *spi,