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
...@@ -559,30 +559,43 @@ static bool spi_ocores_is_busy(struct spi_ocores *sp) ...@@ -559,30 +559,43 @@ static bool spi_ocores_is_busy(struct spi_ocores *sp)
} }
/** /**
* Process an SPI transfer * Pop RX word and push next TX from current transfer
* @sp: SPI OCORE controller * @sp: SPI OCORE controller
* *
* Return: 0 on success, -ENODATA when there is nothing to process * Return: 0 on success, -ENODATA when there is nothing to process
*/ */
static int spi_ocores_process(struct spi_ocores *sp) static int spi_ocores_hw_xfer_rxtx(struct spi_ocores *sp)
{ {
if (spi_ocores_is_busy(sp))
return -EBUSY;
spi_ocores_hw_xfer_rx_pop(sp); spi_ocores_hw_xfer_rx_pop(sp);
if (spi_ocores_sw_xfer_has_pending(sp)) { if (spi_ocores_sw_xfer_has_pending(sp))
return -ENODATA;
spi_ocores_hw_xfer_tx_push(sp); spi_ocores_hw_xfer_tx_push(sp);
spi_ocores_hw_xfer_start(sp); spi_ocores_hw_xfer_start(sp);
} else {
return 0;
}
/**
* Process an SPI transfer
* @sp: SPI OCORE controller
*
* Return: 0 on success, -ENODATA when there is nothing to process
*/
static int spi_ocores_process(struct spi_ocores *sp)
{
int err; int err;
if (spi_ocores_is_busy(sp))
return -EBUSY;
err = spi_ocores_hw_xfer_rxtx(sp);
if (err == -ENODATA) {
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