aboutsummaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorBalaji Rao <balajirrao@openmoko.org>2009-02-26 04:10:49 +0000
committerAndy Green <agreen@octopus.localdomain>2009-02-26 04:10:49 +0000
commit61fb71ae826aa6684e892ccfb73f6fc3bb013f13 (patch)
treec7180a4ce7dd869b164320d987bca283659c4dbc /include/linux
parent83cf37799009f6a3db4fef141c798c876124954f (diff)
Subject: spi_supoport_non_blocking_sync_transfers.patch
X-Git-Url: http://git.openmoko.org/?p=kernel.git;a=commitdiff_plain;h=f8fbb07854e3aff64dce9fe6ef6a8dc0e0f762b5 spi_supoport_non_blocking_sync_transfers.patch A mew option is added to spi_bitbang_info to specify if the transfers off it will be non blocking. A new function - spi_non_blocking_transfer is added to the SPI core. Signed-off-by: Balaji Rao <balajirrao@openmoko.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/spi/spi.h30
-rw-r--r--include/linux/spi/spi_bitbang.h5
2 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 68bb1c501d0..bf21ef63984 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -264,6 +264,13 @@ struct spi_master {
int (*transfer)(struct spi_device *spi,
struct spi_message *mesg);
+ /*
+ * Synchronous non blocking transfer function. Should guarantee
+ * data availability when it returns
+ */
+ int (*transfer_sync)(struct spi_device *spi,
+ struct spi_message *mesg);
+
/* called on release() to free memory provided by spi_master */
void (*cleanup)(struct spi_device *spi);
};
@@ -573,6 +580,29 @@ spi_async(struct spi_device *spi, struct spi_message *message)
return spi->master->transfer(spi, message);
}
+/**
+ * spi_non_blocking_transfer - Synchronous, non blocking transfer
+ * @spi: device with which data will be exchanged
+ * @message: describes the data transfers with optional completion handlers
+ * Context: any (irqs may be blocked, etc)
+ *
+ * Data is guaranteed to be written or read when this function returns.
+ *
+ * Note : This may not be supported by all spi masters.
+ */
+
+static inline int
+spi_non_blocking_transfer(struct spi_device *spi, struct spi_message *message)
+{
+ if (unlikely(!spi->master->transfer_sync)) {
+ dev_err(&spi->master->dev,
+ "non-blocking transfers not supported\n");
+ return -EIO;
+ }
+
+ return spi->master->transfer_sync(spi, message);
+}
+
/*---------------------------------------------------------------------------*/
/* All these synchronous SPI transfer routines are utilities layered
diff --git a/include/linux/spi/spi_bitbang.h b/include/linux/spi/spi_bitbang.h
index bf8de281b4e..476a7afdc97 100644
--- a/include/linux/spi/spi_bitbang.h
+++ b/include/linux/spi/spi_bitbang.h
@@ -31,6 +31,9 @@ struct spi_bitbang {
u8 use_dma;
u8 flags; /* extra spi->mode support */
+ /* Support for synchronous non blocking transfers */
+ int non_blocking_transfer;
+
struct spi_master *master;
/* setup_transfer() changes clock and/or wordsize to match settings
@@ -62,6 +65,8 @@ extern void spi_bitbang_cleanup(struct spi_device *spi);
extern int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m);
extern int spi_bitbang_setup_transfer(struct spi_device *spi,
struct spi_transfer *t);
+extern int spi_bitbang_transfer_sync(struct spi_device *spi,
+ struct spi_message *m);
/* start or stop queue processing */
extern int spi_bitbang_start(struct spi_bitbang *spi);