From 3b1884c24c98dada51fc4b05735773f0078711d2 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 30 Nov 2015 15:28:06 +0100 Subject: spi: Uninline spi_unregister_device() Uninline spi_unregister_device() in preparation of adding more code to it. Add kerneldoc documentation while we're at it. Signed-off-by: Geert Uytterhoeven Signed-off-by: Mark Brown --- include/linux/spi/spi.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'include/linux/spi') diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index cce80e6..075bede 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -1115,12 +1115,7 @@ spi_add_device(struct spi_device *spi); extern struct spi_device * spi_new_device(struct spi_master *, struct spi_board_info *); -static inline void -spi_unregister_device(struct spi_device *spi) -{ - if (spi) - device_unregister(&spi->dev); -} +extern void spi_unregister_device(struct spi_device *spi); extern const struct spi_device_id * spi_get_device_id(const struct spi_device *sdev); -- cgit v1.1 From 49ddedf3bfcb59a562c7db0e50aecd1422e9cdc9 Mon Sep 17 00:00:00 2001 From: Martin Sperl Date: Fri, 27 Nov 2015 13:56:03 +0000 Subject: spi: add spi_message_init_no_memset to avoid zeroing the spi_message In the spi_loopback_test driver there is the need to initialize a spi_message that is filled with values from a static structure. Applying spi_message_init to such a prefilled structure results in all the settings getting reset to zero, which is not what we want. Copying each field of spi_message separately instead always includes the risk that some new fields have not been implemented in the copying code. So here we introduce a version of spi_message_init called spi_message_init_no_memset that does not fill the structure with zero first, but only initializes the relevant list_heads. Signed-off-by: Martin Sperl Signed-off-by: Mark Brown --- include/linux/spi/spi.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include/linux/spi') diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index cce80e6..4c54d47 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -762,10 +762,15 @@ struct spi_message { void *state; }; +static inline void spi_message_init_no_memset(struct spi_message *m) +{ + INIT_LIST_HEAD(&m->transfers); +} + static inline void spi_message_init(struct spi_message *m) { memset(m, 0, sizeof *m); - INIT_LIST_HEAD(&m->transfers); + spi_message_init_no_memset(m); } static inline void -- cgit v1.1 From 4acad4aae10d1fa79a075b38b5c73772c44f576c Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Wed, 2 Dec 2015 10:38:21 +0000 Subject: 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 Signed-off-by: Mark Brown --- include/linux/spi/spi.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/linux/spi') diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index cce80e6..3eebc6c 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -425,6 +425,12 @@ struct spi_master { #define SPI_MASTER_MUST_RX BIT(3) /* requires rx */ #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 */ spinlock_t bus_lock_spinlock; 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, 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 -- cgit v1.1