spi_write_then_read — SPI synchronous write followed by read
int spi_write_then_read
(struct spi_device * spi, const u8 * txbuf, unsigned n_tx, u8 * rxbuf, unsigned n_rx);
device with which data will be exchanged
data to be written (need not be dma-safe)
size of txbuf, in bytes
buffer into which data will be read
size of rxbuf, in bytes (need not be dma-safe)
can sleep
This performs a half duplex MicroWire style transaction with the device, sending txbuf and then reading rxbuf. The return value is zero for success, else a negative errno status code. This call may only be used from a context that may sleep.
Parameters to this routine are always copied using a small buffer; portable code should never use this for more than 32 bytes. Performance-sensitive or bulk transfer code should instead use spi_{async,sync}() calls with dma-safe buffers.