Skip to content

Commit

Permalink
spi: npcm: Modify pspi send function
Browse files Browse the repository at this point in the history
Align pspi send function code with the recieve function
code, Also simplify the code a bit with early return.

Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Tomer Maimon authored and Mark Brown committed Dec 6, 2018
1 parent 194276b commit 1fa33be
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions drivers/spi/spi-npcm-pspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,22 @@ static void npcm_pspi_send(struct npcm_pspi *priv)
wsize = min(bytes_per_word(priv->bits_per_word), priv->tx_bytes);
priv->tx_bytes -= wsize;

if (priv->tx_buf) {
if (wsize == 1)
iowrite8(*priv->tx_buf, NPCM_PSPI_DATA + priv->base);
if (wsize == 2)
iowrite16(*priv->tx_buf, NPCM_PSPI_DATA + priv->base);
if (!priv->tx_buf)
return;

priv->tx_buf += wsize;
switch (wsize) {
case 1:
iowrite8(*priv->tx_buf, NPCM_PSPI_DATA + priv->base);
break;
case 2:
iowrite16(*priv->tx_buf, NPCM_PSPI_DATA + priv->base);
break;
default:
WARN_ON_ONCE(1);
return;
}

priv->tx_buf += wsize;
}

static void npcm_pspi_recv(struct npcm_pspi *priv)
Expand Down

0 comments on commit 1fa33be

Please sign in to comment.