Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114790
b: refs/heads/master
c: f9b90e3
h: refs/heads/master
v: v3
  • Loading branch information
Vernon Sauder authored and Linus Torvalds committed Oct 16, 2008
1 parent c9a3b53 commit 66a4f94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 62f9e8f15a95822e0a793090ff69b277690c6aa6
refs/heads/master: f9b90e39cbc5c4d6ef60022fd1f25d541df0aad1
22 changes: 8 additions & 14 deletions trunk/drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ int spi_write_then_read(struct spi_device *spi,

int status;
struct spi_message message;
struct spi_transfer x[2];
struct spi_transfer x;
u8 *local_buf;

/* Use preallocated DMA-safe buffer. We can't avoid copying here,
Expand All @@ -671,15 +671,9 @@ int spi_write_then_read(struct spi_device *spi,
return -EINVAL;

spi_message_init(&message);
memset(x, 0, sizeof x);
if (n_tx) {
x[0].len = n_tx;
spi_message_add_tail(&x[0], &message);
}
if (n_rx) {
x[1].len = n_rx;
spi_message_add_tail(&x[1], &message);
}
memset(&x, 0, sizeof x);
x.len = n_tx + n_rx;
spi_message_add_tail(&x, &message);

/* ... unless someone else is using the pre-allocated buffer */
if (!mutex_trylock(&lock)) {
Expand All @@ -690,15 +684,15 @@ int spi_write_then_read(struct spi_device *spi,
local_buf = buf;

memcpy(local_buf, txbuf, n_tx);
x[0].tx_buf = local_buf;
x[1].rx_buf = local_buf + n_tx;
x.tx_buf = local_buf;
x.rx_buf = local_buf;

/* do the i/o */
status = spi_sync(spi, &message);
if (status == 0)
memcpy(rxbuf, x[1].rx_buf, n_rx);
memcpy(rxbuf, x.rx_buf + n_tx, n_rx);

if (x[0].tx_buf == buf)
if (x.tx_buf == buf)
mutex_unlock(&lock);
else
kfree(local_buf);
Expand Down

0 comments on commit 66a4f94

Please sign in to comment.