From: Balaji Rao <balajirrao@openmoko.org>
To: linux-kernel@vger.kernel.org
Cc: spi-devel-general@lists.sourceforge.net,
Andy Green <andy@openmoko.com>,
David Brownell <dbrownell@users.sourceforge.net>
Subject: [PATCH 1/2] spi: Add support for non-blocking synchronous transfers
Date: Sat, 28 Feb 2009 13:40:58 +0530 [thread overview]
Message-ID: <20090228081058.31964.527.stgit@fedora.yogi> (raw)
In-Reply-To: <20090228081036.31964.80618.stgit@fedora.yogi>
A new function namely 'transfer_sync' is added to struct spi_master.
A function 'spi_non_blocking_transfer' is introduced , along the lines
of spi_sync and spi_async.
Signed-off-by: Balaji Rao <balajirrao@openmoko.org>
Cc: Andy Green <andy@openmoko.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: spi-devel-general@lists.sourceforge.net
---
include/linux/spi/spi.h | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 68bb1c5..4466021 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,30 @@ 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.
+ * The completion callback in spi_message is optional.
+ *
+ * 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
next prev parent reply other threads:[~2009-02-28 8:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-28 8:10 [PATCH 0/2] spi: Add support for non-blocking synchronous transfers Balaji Rao
2009-02-28 8:10 ` Balaji Rao [this message]
2009-02-28 8:11 ` [PATCH 2/2] spi_bitbang: " Balaji Rao
2009-02-28 9:09 ` Simon Kagstrom
2009-02-28 9:58 ` Balaji Rao
2009-02-28 10:15 ` Simon Kagstrom
2009-02-28 10:59 ` Balaji Rao
2009-02-28 20:33 ` [PATCH 0/2] spi: " David Brownell
2009-02-28 22:12 ` Balaji Rao
2009-02-28 23:19 ` David Brownell
2009-03-01 5:11 ` Balaji Rao
2009-03-01 9:49 ` David Brownell
2009-03-01 10:23 ` Balaji Rao
2009-03-01 7:48 ` Andy Green
2009-03-01 9:43 ` David Brownell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090228081058.31964.527.stgit@fedora.yogi \
--to=balajirrao@openmoko.org \
--cc=andy@openmoko.com \
--cc=dbrownell@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=spi-devel-general@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox