aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Suchanek <hramrach@gmail.com>2015-12-02 05:38:21 -0500
committerMark Brown <broonie@kernel.org>2016-01-05 11:33:54 -0500
commit4acad4aae10d1fa79a075b38b5c73772c44f576c (patch)
treed0da2a97d6a1f6dec994c0c303feeab11154dac7
parent8005c49d9aea74d382f474ce11afbbc7d7130bec (diff)
spi: expose master transfer size limitation.
On some SPI controllers it is not feasible to transfer arbitrary amount of data at once. When the limit on transfer size is a few kilobytes at least it makes sense to use the SPI hardware rather than reverting to gpio driver. The protocol drivers need a way to check that they do not sent overly long messages, though. Signed-off-by: Michal Suchanek <hramrach@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--include/linux/spi/spi.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index cce80e6dc7d1..3eebc6c235fb 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -425,6 +425,12 @@ struct spi_master {
425#define SPI_MASTER_MUST_RX BIT(3) /* requires rx */ 425#define SPI_MASTER_MUST_RX BIT(3) /* requires rx */
426#define SPI_MASTER_MUST_TX BIT(4) /* requires tx */ 426#define SPI_MASTER_MUST_TX BIT(4) /* requires tx */
427 427
428 /*
429 * on some hardware transfer size may be constrained
430 * the limit may depend on device transfer settings
431 */
432 size_t (*max_transfer_size)(struct spi_device *spi);
433
428 /* lock and mutex for SPI bus locking */ 434 /* lock and mutex for SPI bus locking */
429 spinlock_t bus_lock_spinlock; 435 spinlock_t bus_lock_spinlock;
430 struct mutex bus_lock_mutex; 436 struct mutex bus_lock_mutex;
@@ -832,6 +838,15 @@ extern int spi_async(struct spi_device *spi, struct spi_message *message);
832extern int spi_async_locked(struct spi_device *spi, 838extern int spi_async_locked(struct spi_device *spi,
833 struct spi_message *message); 839 struct spi_message *message);
834 840
841static inline size_t
842spi_max_transfer_size(struct spi_device *spi)
843{
844 struct spi_master *master = spi->master;
845 if (!master->max_transfer_size)
846 return SIZE_MAX;
847 return master->max_transfer_size(spi);
848}
849
835/*---------------------------------------------------------------------------*/ 850/*---------------------------------------------------------------------------*/
836 851
837/* All these synchronous SPI transfer routines are utilities layered 852/* All these synchronous SPI transfer routines are utilities layered