bcm53xx: drop linux 4.4 and 4.9 support
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-4.4 / 000-4.5-20-spi-expose-master-transfer-size-limitation.patch
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.
5
6 On some SPI controllers it is not feasible to transfer arbitrary amount
7 of data at once.
8
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.
11
12 The protocol drivers need a way to check that they do not sent overly
13 long messages, though.
14
15 Signed-off-by: Michal Suchanek <hramrach@gmail.com>
16 Signed-off-by: Mark Brown <broonie@kernel.org>
17 ---
18 include/linux/spi/spi.h | 15 +++++++++++++++
19 1 file changed, 15 insertions(+)
20
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 */
26
27 + /*
28 + * on some hardware transfer size may be constrained
29 + * the limit may depend on device transfer settings
30 + */
31 + size_t (*max_transfer_size)(struct spi_device *spi);
32 +
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);
39
40 +static inline size_t
41 +spi_max_transfer_size(struct spi_device *spi)
42 +{
43 + struct spi_master *master = spi->master;
44 + if (!master->max_transfer_size)
45 + return SIZE_MAX;
46 + return master->max_transfer_size(spi);
47 +}
48 +
49 /*---------------------------------------------------------------------------*/
50
51 /* All these synchronous SPI transfer routines are utilities layered