Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 354482
b: refs/heads/master
c: 6d9eecd
h: refs/heads/master
v: v3
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Feb 9, 2013
1 parent f5eb07e commit 1d5fff6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ad76fda78318821fe8823b4b7c587a46a268eecf
refs/heads/master: 6d9eecd418afb2c12e5db5be3d72f0f1df43bdd9
44 changes: 44 additions & 0 deletions trunk/include/linux/spi/spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,26 @@ spi_transfer_del(struct spi_transfer *t)
list_del(&t->transfer_list);
}

/**
* spi_message_init_with_transfers - Initialize spi_message and append transfers
* @m: spi_message to be initialized
* @xfers: An array of spi transfers
* @num_xfers: Number of items in the xfer array
*
* This function initializes the given spi_message and adds each spi_transfer in
* the given array to the message.
*/
static inline void
spi_message_init_with_transfers(struct spi_message *m,
struct spi_transfer *xfers, unsigned int num_xfers)
{
unsigned int i;

spi_message_init(m);
for (i = 0; i < num_xfers; ++i)
spi_message_add_tail(&xfers[i], m);
}

/* It's fine to embed message and transaction structures in other data
* structures so long as you don't free them while they're in use.
*/
Expand Down Expand Up @@ -683,6 +703,30 @@ spi_read(struct spi_device *spi, void *buf, size_t len)
return spi_sync(spi, &m);
}

/**
* spi_sync_transfer - synchronous SPI data transfer
* @spi: device with which data will be exchanged
* @xfers: An array of spi_transfers
* @num_xfers: Number of items in the xfer array
* Context: can sleep
*
* Does a synchronous SPI data transfer of the given spi_transfer array.
*
* For more specific semantics see spi_sync().
*
* It returns zero on success, else a negative error code.
*/
static inline int
spi_sync_transfer(struct spi_device *spi, struct spi_transfer *xfers,
unsigned int num_xfers)
{
struct spi_message msg;

spi_message_init_with_transfers(&msg, xfers, num_xfers);

return spi_sync(spi, &msg);
}

/* this copies txbuf and rxbuf data; for small transfers only! */
extern int spi_write_then_read(struct spi_device *spi,
const void *txbuf, unsigned n_tx,
Expand Down

0 comments on commit 1d5fff6

Please sign in to comment.