The spi_dma_xchange() function uses DMA to exchange data between the SPI master and an SPI device. The prototype for this function is:
int spi_dma_xchange( int fd,
uint32_t device,
void *wbuf,
void *rbuf,
int len );
The arguments are:
This function calls spi_dma_xfer() to do the actual DMA. If you're using the same buffer repeatedly, it's more efficient to call spi_dma_xfer() directly.
The spi_dma_xchange() function returns the number of bytes of data that it successfully exchanged. If an error occurred, the function returns -1 and sets errno:
An SPI driver typically considers it to be an error if the number of bytes returned by this function isn't the same as the number of bytes it asked the function to exchange.