Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / include / linux / spi / spi.h
index 1619ed48e75d19c2fa6dd01061af962a417d0754..8c62ba74dd91d9800439038d86298f2e2477f1fe 100644 (file)
@@ -853,6 +853,33 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd)
        return (status < 0) ? status : result;
 }
 
+/**
+ * spi_w8r16be - SPI synchronous 8 bit write followed by 16 bit big-endian read
+ * @spi: device with which data will be exchanged
+ * @cmd: command to be written before data is read back
+ * Context: can sleep
+ *
+ * This returns the (unsigned) sixteen bit number returned by the device in cpu
+ * endianness, or else a negative error code. Callable only from contexts that
+ * can sleep.
+ *
+ * This function is similar to spi_w8r16, with the exception that it will
+ * convert the read 16 bit data word from big-endian to native endianness.
+ *
+ */
+static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd)
+
+{
+       ssize_t status;
+       __be16 result;
+
+       status = spi_write_then_read(spi, &cmd, 1, &result, 2);
+       if (status < 0)
+               return status;
+
+       return be16_to_cpu(result);
+}
+
 /*---------------------------------------------------------------------------*/
 
 /*