From: luowei Date: Fri, 7 Mar 2014 11:06:04 +0000 (+0800) Subject: add spi_write_and_read interface for spi X-Git-Tag: firefly_0821_release~6165^2~7^2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9f2f43526db641600690f4f330df0a1b038a6edf;p=firefly-linux-kernel-4.4.55.git add spi_write_and_read interface for spi --- diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h old mode 100644 new mode 100755 index 6ff26c8db7b9..28c101bf79f5 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -716,6 +716,23 @@ spi_read(struct spi_device *spi, void *buf, size_t len) return spi_sync(spi, &m); } + +static inline int +spi_write_and_read(struct spi_device *spi, const void *tx_buf, void *rx_buf, size_t len) +{ + struct spi_transfer t = { + .tx_buf = tx_buf, + .rx_buf = rx_buf, + .len = len, + }; + struct spi_message m; + + spi_message_init(&m); + spi_message_add_tail(&t, &m); + return spi_sync(spi, &m); +} + + /** * spi_sync_transfer - synchronous SPI data transfer * @spi: device with which data will be exchanged