Skip to content

Commit

Permalink
spi: altera: fix return value for altera_spi_txrx()
Browse files Browse the repository at this point in the history
This patch fixes the return value for altera_spi_txrx. It should return
1 for interrupt transfer mode, and return 0 for polling transfer mode.

The altera_spi_txrx() implements the spi_controller.transfer_one
callback. According to the spi-summary.rst, the transfer_one should
return 0 when transfer is finished, return 1 when transfer is still in
progress.

Signed-off-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/1609219662-27057-2-git-send-email-yilun.xu@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Xu Yilun authored and Mark Brown committed Dec 29, 2020
1 parent 8db90aa commit ede090f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions drivers/spi/spi-altera.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,26 @@ static int altera_spi_txrx(struct spi_master *master,

/* send the first byte */
altera_spi_tx_word(hw);
} else {
while (hw->count < hw->len) {
altera_spi_tx_word(hw);

for (;;) {
altr_spi_readl(hw, ALTERA_SPI_STATUS, &val);
if (val & ALTERA_SPI_STATUS_RRDY_MSK)
break;
return 1;
}

while (hw->count < hw->len) {
altera_spi_tx_word(hw);

cpu_relax();
}
for (;;) {
altr_spi_readl(hw, ALTERA_SPI_STATUS, &val);
if (val & ALTERA_SPI_STATUS_RRDY_MSK)
break;

altera_spi_rx_word(hw);
cpu_relax();
}
spi_finalize_current_transfer(master);

altera_spi_rx_word(hw);
}
spi_finalize_current_transfer(master);

return t->len;
return 0;
}

static irqreturn_t altera_spi_irq(int irq, void *dev)
Expand Down

0 comments on commit ede090f

Please sign in to comment.