aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/spi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 15:11:44 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 15:11:44 -0500
commitb5c78e04dd061b776978dad61dd85357081147b0 (patch)
tree2416b2dc61c452c3aeb2a32bcedf15e6257be638 /include/linux/spi
parent06991c28f37ad68e5c03777f5c3b679b56e3dac1 (diff)
parent951348b377385475aa256c27e1c9e2564c9ec160 (diff)
Merge tag 'staging-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging tree update from Greg Kroah-Hartman: "Here's the big staging tree merge for 3.9-rc1 Lots of cleanups and updates for drivers all through the staging tree. We are pretty much "code neutral" here, adding just about as many lines as we removed. All of these have been in linux-next for a while." * tag 'staging-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (804 commits) staging: comedi: vmk80xx: wait for URBs to complete staging: comedi: drivers: addi-data: hwdrv_apci3200.c: Add a missing semicolon staging: et131x: Update TODO list staging: et131x: Remove assignment of skb->dev staging: wlan-ng: hfa384x.h: fix for error reported by smatch staging/zache checkpatch ERROR: spaces prohibited around that staging/ozwpan: Mark read only parameters and structs as const staging/ozwpan: Remove empty and unused function oz_cdev_heartbeat staging/ozwpan: Mark local functions as static (fix sparse warnings) staging/ozwpan: Add missing header includes staging/usbip: Mark local functions as static (fix sparse warnings) staging/xgifb: Remove duplicated code in loops. staging/xgifb: Consolidate return paths staging/xgifb: Remove code without effect staging/xgifb: Remove unnecessary casts staging/xgifb: Consolidate if/else if with identical code branches staging: vt6656: replaced custom TRUE definition with true staging: vt6656: replaced custom FALSE definition with false staging: vt6656: replace custom BOOL definition with bool staging/rtl8187se: Mark functions as static to silence sparse ...
Diffstat (limited to 'include/linux/spi')
-rw-r--r--include/linux/spi/spi.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 30e9c50a5e20..38c2b925923d 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -596,6 +596,26 @@ spi_transfer_del(struct spi_transfer *t)
596 list_del(&t->transfer_list); 596 list_del(&t->transfer_list);
597} 597}
598 598
599/**
600 * spi_message_init_with_transfers - Initialize spi_message and append transfers
601 * @m: spi_message to be initialized
602 * @xfers: An array of spi transfers
603 * @num_xfers: Number of items in the xfer array
604 *
605 * This function initializes the given spi_message and adds each spi_transfer in
606 * the given array to the message.
607 */
608static inline void
609spi_message_init_with_transfers(struct spi_message *m,
610struct spi_transfer *xfers, unsigned int num_xfers)
611{
612 unsigned int i;
613
614 spi_message_init(m);
615 for (i = 0; i < num_xfers; ++i)
616 spi_message_add_tail(&xfers[i], m);
617}
618
599/* It's fine to embed message and transaction structures in other data 619/* It's fine to embed message and transaction structures in other data
600 * structures so long as you don't free them while they're in use. 620 * structures so long as you don't free them while they're in use.
601 */ 621 */
@@ -688,6 +708,30 @@ spi_read(struct spi_device *spi, void *buf, size_t len)
688 return spi_sync(spi, &m); 708 return spi_sync(spi, &m);
689} 709}
690 710
711/**
712 * spi_sync_transfer - synchronous SPI data transfer
713 * @spi: device with which data will be exchanged
714 * @xfers: An array of spi_transfers
715 * @num_xfers: Number of items in the xfer array
716 * Context: can sleep
717 *
718 * Does a synchronous SPI data transfer of the given spi_transfer array.
719 *
720 * For more specific semantics see spi_sync().
721 *
722 * It returns zero on success, else a negative error code.
723 */
724static inline int
725spi_sync_transfer(struct spi_device *spi, struct spi_transfer *xfers,
726 unsigned int num_xfers)
727{
728 struct spi_message msg;
729
730 spi_message_init_with_transfers(&msg, xfers, num_xfers);
731
732 return spi_sync(spi, &msg);
733}
734
691/* this copies txbuf and rxbuf data; for small transfers only! */ 735/* this copies txbuf and rxbuf data; for small transfers only! */
692extern int spi_write_then_read(struct spi_device *spi, 736extern int spi_write_then_read(struct spi_device *spi,
693 const void *txbuf, unsigned n_tx, 737 const void *txbuf, unsigned n_tx,