From 89c1f60746106755e29dcc3db9f22e37000891ef Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Fri, 13 Dec 2013 18:27:44 -0800 Subject: spi: Order fields in spi_device for better packing Now that spi_device->mode is a u16, the chip_select, bits_per_mode, and mode fields pack poorly, taking 8 bytes: four data and four padding. By moving (u8)bits_per_word up one position, to after (u8)chip_select, they pack better and only use 4 bytes. Signed-off-by: Trent Piepho Reviewed-by: Sourav Poddar Tested-by: Sourav Poddar g Signed-off-by: Mark Brown --- include/linux/spi/spi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 8c62ba74dd91..27a882978c15 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -75,6 +75,7 @@ struct spi_device { struct spi_master *master; u32 max_speed_hz; u8 chip_select; + u8 bits_per_word; u16 mode; #define SPI_CPHA 0x01 /* clock phase */ #define SPI_CPOL 0x02 /* clock polarity */ @@ -92,7 +93,6 @@ struct spi_device { #define SPI_TX_QUAD 0x200 /* transmit with 4 wires */ #define SPI_RX_DUAL 0x400 /* receive with 2 wires */ #define SPI_RX_QUAD 0x800 /* receive with 4 wires */ - u8 bits_per_word; int irq; void *controller_state; void *controller_data; -- cgit v1.2.3 From 7c7ccc52fc7b6d75bb7604a59cc641fa6336b619 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 30 Dec 2013 11:56:42 +0530 Subject: spi: nuc900: Cleanup spi-nuc900.h header Commit 54ecf4f05637 ("ARM: w90x900: move platform_data definitions") moved the file to the current location but forgot to remove the pointer to its previous location. Clean it up. While at it also change the header file protection macros appropriately. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- include/linux/platform_data/spi-nuc900.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/linux/platform_data/spi-nuc900.h b/include/linux/platform_data/spi-nuc900.h index 2c4e0c128501..4b3f46832e19 100644 --- a/include/linux/platform_data/spi-nuc900.h +++ b/include/linux/platform_data/spi-nuc900.h @@ -1,6 +1,4 @@ /* - * arch/arm/mach-w90x900/include/mach/nuc900_spi.h - * * Copyright (c) 2009 Nuvoton technology corporation. * * Wan ZongShun @@ -11,8 +9,8 @@ * */ -#ifndef __ASM_ARCH_SPI_H -#define __ASM_ARCH_SPI_H +#ifndef __SPI_NUC900_H +#define __SPI_NUC900_H extern void mfp_set_groupg(struct device *dev, const char *subname); @@ -32,4 +30,4 @@ struct nuc900_spi_chip { unsigned char bits_per_word; }; -#endif /* __ASM_ARCH_SPI_H */ +#endif /* __SPI_NUC900_H */ -- cgit v1.2.3 From 85a9012446d4b59a57c5942ca059144fdf8cd439 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 31 Dec 2013 14:00:39 +0530 Subject: spi: s3c24xx: Remove reference to plat/fiq.h fiq.h contains only a function declaration and is not used by anyone else. Move the declaration to the driver header file and remove the unnecessary platform dependency from the driver. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- include/linux/spi/s3c24xx.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/spi/s3c24xx.h b/include/linux/spi/s3c24xx.h index c23b923e493b..ca271c06c591 100644 --- a/include/linux/spi/s3c24xx.h +++ b/include/linux/spi/s3c24xx.h @@ -23,4 +23,6 @@ struct s3c2410_spi_info { void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol); }; +extern int s3c24xx_set_fiq(unsigned int irq, bool on); + #endif /* __LINUX_SPI_S3C24XX_H */ -- cgit v1.2.3 From d3fbd457013c0f6d96de461ce0a9cb1f8b73cd0b Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 10 Jan 2014 17:09:53 +0000 Subject: spi: Use bitfields for multiple data lines Trent Piepho observed that since the current realistic maximum number of data lines is four we can pack the spi_transfer struct more efficiently if we use a bitfield for the number of bits, allowing the fields to fit in a single byte along with cs_change. If space becomes an issue further optimiation is possible by only using the constants and packing the values chosen for them. Reported-by: Trent Piepho Signed-off-by: Mark Brown --- include/linux/spi/spi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 27a882978c15..77b529e418d5 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -576,8 +576,8 @@ struct spi_transfer { dma_addr_t rx_dma; unsigned cs_change:1; - u8 tx_nbits; - u8 rx_nbits; + unsigned tx_nbits:3; + unsigned rx_nbits:3; #define SPI_NBITS_SINGLE 0x01 /* 1bit transfer */ #define SPI_NBITS_DUAL 0x02 /* 2bits transfer */ #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */ -- cgit v1.2.3 From 269ccca8ec1a3991e07eaf5f90326134bd17781a Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 12 Jan 2014 13:59:06 +0100 Subject: spi: Kill superfluous cast in spi_w8r16() spi_write_then_read() takes a "void *" for rxbuf, so there's no need to cast the buffer pointer to "u8 *". Signed-off-by: Geert Uytterhoeven Signed-off-by: Mark Brown --- include/linux/spi/spi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 77b529e418d5..21a7251d85ee 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -847,7 +847,7 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd) ssize_t status; u16 result; - status = spi_write_then_read(spi, &cmd, 1, (u8 *) &result, 2); + status = spi_write_then_read(spi, &cmd, 1, &result, 2); /* return negative errno or unsigned value */ return (status < 0) ? status : result; -- cgit v1.2.3 From 0516712c6548e252adf7aebf70d67842cd734483 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 21 Jan 2014 16:10:06 +0100 Subject: spi: Clarify transfer_one() w.r.t. spi_finalize_current_transfer() Signed-off-by: Geert Uytterhoeven Signed-off-by: Mark Brown --- include/linux/spi/spi.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 8c62ba74dd91..e766e0e2fe58 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -282,10 +282,12 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) * @prepare_message: set up the controller to transfer a single message, * for example doing DMA mapping. Called from threaded * context. - * @transfer_one: transfer a single spi_transfer. When the - * driver is finished with this transfer it must call - * spi_finalize_current_transfer() so the subsystem can issue - * the next transfer + * @transfer_one: transfer a single spi_transfer. + * - return 0 if the transfer is finished, + * - return 1 if the transfer is still in progress. When + * the driver is finished with this transfer it must + * call spi_finalize_current_transfer() so the subsystem + * can issue the next transfer * @unprepare_message: undo any work done by prepare_message(). * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS * number. Any individual value may be -ENOENT for CS lines that -- cgit v1.2.3 From bd6857a0c630207484a03ddc470fab34b23f80bb Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 21 Jan 2014 16:10:07 +0100 Subject: spi: Correct set_cs() documentation The documentation for spi_master.set_cs() says: assert or deassert chip select, true to assert i.e. its "enable" parameter uses assertion-level logic. This does not match the implementation of spi_set_cs(), which calls spi_master.set_cs() with the wanted logic level of the chip select line, which depends on the polarity of the chip select signal. Correct the documentation to match the implementation. Signed-off-by: Geert Uytterhoeven Signed-off-by: Mark Brown --- include/linux/spi/spi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index e766e0e2fe58..9f5242df9311 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -277,7 +277,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) * @unprepare_transfer_hardware: there are currently no more messages on the * queue so the subsystem notifies the driver that it may relax the * hardware by issuing this call - * @set_cs: assert or deassert chip select, true to assert. May be called + * @set_cs: set the logic level of the chip select line. May be called * from interrupt context. * @prepare_message: set up the controller to transfer a single message, * for example doing DMA mapping. Called from threaded -- cgit v1.2.3