add spi_write_and_read interface for spi
authorluowei <lw@rock-chips.com>
Fri, 7 Mar 2014 11:06:04 +0000 (19:06 +0800)
committerluowei <lw@rock-chips.com>
Fri, 7 Mar 2014 11:06:04 +0000 (19:06 +0800)
include/linux/spi/spi.h [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 6ff26c8..28c101b
@@ -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