diff options
author | Mark A. Greer <mgreer@animalcreek.com> | 2014-09-02 15:12:18 -0700 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-09-07 23:13:42 +0200 |
commit | 3e7f335689ebfa0a68814dfe9f0588076fb9ad01 (patch) | |
tree | f631f125dffa6619c0bfb3f5e92a053903156a74 /drivers/nfc | |
parent | 24707296c762d1828c4a51aa1872dc275dc3fccc (diff) |
NFC: trf7970a: Use spi_sync() instead of spi_write_then_read()
To more efficiently handle long continuous reads,
use spi_sync() instead of spi_write_then_read().
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/trf7970a.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c index 159b0a3f965b..badd2c7ffa92 100644 --- a/drivers/nfc/trf7970a.c +++ b/drivers/nfc/trf7970a.c @@ -393,15 +393,28 @@ static int trf7970a_read(struct trf7970a *trf, u8 reg, u8 *val) return ret; } -static int trf7970a_read_cont(struct trf7970a *trf, u8 reg, - u8 *buf, size_t len) +static int trf7970a_read_cont(struct trf7970a *trf, u8 reg, u8 *buf, size_t len) { u8 addr = reg | TRF7970A_CMD_BIT_RW | TRF7970A_CMD_BIT_CONTINUOUS; + struct spi_transfer t[2]; + struct spi_message m; int ret; dev_dbg(trf->dev, "read_cont(0x%x, %zd)\n", addr, len); - ret = spi_write_then_read(trf->spi, &addr, 1, buf, len); + spi_message_init(&m); + + memset(&t, 0, sizeof(t)); + + t[0].tx_buf = &addr; + t[0].len = sizeof(addr); + spi_message_add_tail(&t[0], &m); + + t[1].rx_buf = buf; + t[1].len = len; + spi_message_add_tail(&t[1], &m); + + ret = spi_sync(trf->spi, &m); if (ret) dev_err(trf->dev, "%s - addr: 0x%x, ret: %d\n", __func__, addr, ret); |