1 From 4acad4aae10d1fa79a075b38b5c73772c44f576c Mon Sep 17 00:00:00 2001
2 From: Michal Suchanek <hramrach@gmail.com>
3 Date: Wed, 2 Dec 2015 10:38:21 +0000
4 Subject: [PATCH] spi: expose master transfer size limitation.
6 On some SPI controllers it is not feasible to transfer arbitrary amount
9 When the limit on transfer size is a few kilobytes at least it makes
10 sense to use the SPI hardware rather than reverting to gpio driver.
12 The protocol drivers need a way to check that they do not sent overly
13 long messages, though.
15 Signed-off-by: Michal Suchanek <hramrach@gmail.com>
16 Signed-off-by: Mark Brown <broonie@kernel.org>
18 include/linux/spi/spi.h | 15 +++++++++++++++
19 1 file changed, 15 insertions(+)
21 --- a/include/linux/spi/spi.h
22 +++ b/include/linux/spi/spi.h
23 @@ -428,6 +428,12 @@ struct spi_master {
24 #define SPI_MASTER_MUST_RX BIT(3) /* requires rx */
25 #define SPI_MASTER_MUST_TX BIT(4) /* requires tx */
28 + * on some hardware transfer size may be constrained
29 + * the limit may depend on device transfer settings
31 + size_t (*max_transfer_size)(struct spi_device *spi);
33 /* lock and mutex for SPI bus locking */
34 spinlock_t bus_lock_spinlock;
35 struct mutex bus_lock_mutex;
36 @@ -837,6 +843,15 @@ extern int spi_async(struct spi_device *
37 extern int spi_async_locked(struct spi_device *spi,
38 struct spi_message *message);
41 +spi_max_transfer_size(struct spi_device *spi)
43 + struct spi_master *master = spi->master;
44 + if (!master->max_transfer_size)
46 + return master->max_transfer_size(spi);
49 /*---------------------------------------------------------------------------*/
51 /* All these synchronous SPI transfer routines are utilities layered