Commit 94d7d1c2 authored by Federico Vaga's avatar Federico Vaga

sw:drv:spi: group full-duplex operations in una function

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent dba5e3ac
...@@ -558,6 +558,24 @@ static bool spi_ocores_is_busy(struct spi_ocores *sp) ...@@ -558,6 +558,24 @@ static bool spi_ocores_is_busy(struct spi_ocores *sp)
return (ctrl & SPI_OCORES_CTRL_BUSY); return (ctrl & SPI_OCORES_CTRL_BUSY);
} }
/**
* Pop RX word and push next TX from current transfer
* @sp: SPI OCORE controller
*
* Return: 0 on success, -ENODATA when there is nothing to process
*/
static int spi_ocores_hw_xfer_rxtx(struct spi_ocores *sp)
{
spi_ocores_hw_xfer_rx_pop(sp);
if (spi_ocores_sw_xfer_has_pending(sp))
return -ENODATA;
spi_ocores_hw_xfer_tx_push(sp);
spi_ocores_hw_xfer_start(sp);
return 0;
}
/** /**
* Process an SPI transfer * Process an SPI transfer
* @sp: SPI OCORE controller * @sp: SPI OCORE controller
...@@ -566,22 +584,17 @@ static bool spi_ocores_is_busy(struct spi_ocores *sp) ...@@ -566,22 +584,17 @@ static bool spi_ocores_is_busy(struct spi_ocores *sp)
*/ */
static int spi_ocores_process(struct spi_ocores *sp) static int spi_ocores_process(struct spi_ocores *sp)
{ {
int err;
if (spi_ocores_is_busy(sp)) if (spi_ocores_is_busy(sp))
return -EBUSY; return -EBUSY;
spi_ocores_hw_xfer_rx_pop(sp); err = spi_ocores_hw_xfer_rxtx(sp);
if (spi_ocores_sw_xfer_has_pending(sp)) { if (err == -ENODATA) {
spi_ocores_hw_xfer_tx_push(sp);
spi_ocores_hw_xfer_start(sp);
} else {
int err;
spi_ocores_sw_xfer_finish(sp); spi_ocores_sw_xfer_finish(sp);
err = spi_ocores_sw_xfer_next_start(sp); err = spi_ocores_sw_xfer_next_start(sp);
if (err) { if (err)
/* Error or no more transfers */
spi_ocores_finalize_current_message(sp); spi_ocores_finalize_current_message(sp);
}
} }
return 0; return 0;
...@@ -614,7 +627,7 @@ static irqreturn_t spi_ocores_irq_handler(int irq, void *arg) ...@@ -614,7 +627,7 @@ static irqreturn_t spi_ocores_irq_handler(int irq, void *arg)
int err; int err;
err = spi_ocores_process(sp); err = spi_ocores_process(sp);
if (err) if (err && err != -ENODATA)
return IRQ_NONE; return IRQ_NONE;
return IRQ_HANDLED; return IRQ_HANDLED;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment