X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fspi%2Fspi.c;h=3734dc9708e12669070ab984cc2fe9f0fbee1b70;hb=b6a4b7de4cb45ccf7157fc58de09c96f84d67108;hp=75e86865234c924a67bb94d39c3fc259a6925b5a;hpb=d121db94eb50b29a202b5f6a8671cbebdf2c4142;p=linux-2.6-omap-h63xx.git diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 75e86865234..3734dc9708e 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -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, @@ -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)) { @@ -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); @@ -744,5 +738,5 @@ err0: * driver registration) _could_ be dynamically linked (modular) ... costs * include needing to have boardinfo data structures be much more public. */ -subsys_initcall(spi_init); +postcore_initcall(spi_init);