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>
This commit is contained in:
parent
8005c49d9a
commit
4acad4aae1
|
@ -425,6 +425,12 @@ struct spi_master {
|
||||||
#define SPI_MASTER_MUST_RX BIT(3) /* requires rx */
|
#define SPI_MASTER_MUST_RX BIT(3) /* requires rx */
|
||||||
#define SPI_MASTER_MUST_TX BIT(4) /* requires tx */
|
#define SPI_MASTER_MUST_TX BIT(4) /* requires tx */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* on some hardware transfer size may be constrained
|
||||||
|
* the limit may depend on device transfer settings
|
||||||
|
*/
|
||||||
|
size_t (*max_transfer_size)(struct spi_device *spi);
|
||||||
|
|
||||||
/* lock and mutex for SPI bus locking */
|
/* lock and mutex for SPI bus locking */
|
||||||
spinlock_t bus_lock_spinlock;
|
spinlock_t bus_lock_spinlock;
|
||||||
struct mutex bus_lock_mutex;
|
struct mutex bus_lock_mutex;
|
||||||
|
@ -832,6 +838,15 @@ extern int spi_async(struct spi_device *spi, struct spi_message *message);
|
||||||
extern int spi_async_locked(struct spi_device *spi,
|
extern int spi_async_locked(struct spi_device *spi,
|
||||||
struct spi_message *message);
|
struct spi_message *message);
|
||||||
|
|
||||||
|
static inline size_t
|
||||||
|
spi_max_transfer_size(struct spi_device *spi)
|
||||||
|
{
|
||||||
|
struct spi_master *master = spi->master;
|
||||||
|
if (!master->max_transfer_size)
|
||||||
|
return SIZE_MAX;
|
||||||
|
return master->max_transfer_size(spi);
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* All these synchronous SPI transfer routines are utilities layered
|
/* All these synchronous SPI transfer routines are utilities layered
|
||||||
|
|
Loading…
Reference in New Issue