Skip to content

Commit ede090f

Browse files
yilunxu1984broonie
authored andcommitted
spi: altera: fix return value for altera_spi_txrx()
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 8db90aa commit ede090f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

drivers/spi/spi-altera.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,24 +189,26 @@ static int altera_spi_txrx(struct spi_master *master,
189189

190190
/* send the first byte */
191191
altera_spi_tx_word(hw);
192-
} else {
193-
while (hw->count < hw->len) {
194-
altera_spi_tx_word(hw);
195192

196-
for (;;) {
197-
altr_spi_readl(hw, ALTERA_SPI_STATUS, &val);
198-
if (val & ALTERA_SPI_STATUS_RRDY_MSK)
199-
break;
193+
return 1;
194+
}
195+
196+
while (hw->count < hw->len) {
197+
altera_spi_tx_word(hw);
200198

201-
cpu_relax();
202-
}
199+
for (;;) {
200+
altr_spi_readl(hw, ALTERA_SPI_STATUS, &val);
201+
if (val & ALTERA_SPI_STATUS_RRDY_MSK)
202+
break;
203203

204-
altera_spi_rx_word(hw);
204+
cpu_relax();
205205
}
206-
spi_finalize_current_transfer(master);
206+
207+
altera_spi_rx_word(hw);
207208
}
209+
spi_finalize_current_transfer(master);
208210

209-
return t->len;
211+
return 0;
210212
}
211213

212214
static irqreturn_t altera_spi_irq(int irq, void *dev)

0 commit comments

Comments
 (0)