SPI/ Input: ads7846: properly handle spi->mode flags
Subsystems (3)
v2 cover SPI/ Input: ads7846: properly handle spi->mode flags
changes v2:
- add SPI_MODE_X_MASK macro
- ads7846: clear SPI_MODE_X_MASK bits to set driver specific mode.
Oleksij Rempel (2):
spi: introduce SPI_MODE_X_MASK macro
Input: ads7846: do not overwrite spi->mode flags set by spi framework
drivers/input/touchscreen/ads7846.c | 3 ++- include/linux/spi/spi.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
Signature · 1 line
2.28.0
PATCH v2 1/2 spi: introduce SPI_MODE_X_MASK macro
Provide a macro to filter all SPI_MODE_0,1,2,3 mode in one run.
The latest SPI framework will parse the devicetree in following call
sequence: of_register_spi_device() -> of_spi_parse_dt() So, driver do not need to pars the devicetree and will get prepared flags in the probe.
On one hand it is good far most drivers. On other hand some drivers need to filter flags provide by SPI framework and apply know to work flags. This drivers may use SPI_MODE_X_MASK to filter MODE flags and set own, known flags:
spi->flags &= ~SPI_MODE_X_MASK;
spi->flags |= SPI_MODE_0;
--- include/linux/spi/spi.h | 1 + 1 file changed, 1 insertion(+)
include/linux/spi/spi.h +1 -0
@@ -171,6 +171,7 @@ struct spi_device {#define SPI_MODE_1 (0|SPI_CPHA)#define SPI_MODE_2 (SPI_CPOL|0)#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA) +#define SPI_MODE_X_MASK (SPI_CPOL|SPI_CPHA)#define SPI_CS_HIGH 0x04/* chipselect active high? */ #define SPI_LSB_FIRST 0x08/* per-word bits-on-wire */ #define SPI_3WIRE 0x10/* SI/SO signals shared */
Signature · 1 line
2.28.0
PATCH v2 2/2 Input: ads7846: do not overwrite spi->mode flags set by spi framework
In reply to Oleksij RempelDo not overwrite spi->mode flags set by spi framework, otherwise the chip select polarity will get lost.
--- drivers/input/touchscreen/ads7846.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/input/touchscreen/ads7846.c +2 -1
@@ -1288,7 +1288,8 @@ static int ads7846_probe(struct spi_device *spi)* may not. So we stick to very-portable 8 bit words, both RX and TX. */ spi->bits_per_word =8 ; - spi->mode =SPI_MODE_0 ; + spi->mode &= ~SPI_MODE_X_MASK ; + spi->mode |=SPI_MODE_0 ; err =spi_setup (spi);if (err <0 )return err;
Signature · 1 line
2.28.0
Re: [PATCH v2 2/2] Input: ads7846: do not overwrite spi->mode flags set by spi framework
Hello Dmitry,
ping for this patch as well.
Regards,
Oleksij
Quoted 26 lines · Oleksij Rempel
Do not overwrite
spi->modeflags set by spi framework, otherwise the chip select polarity will get lost.Signed-off-by Oleksij Rempel <[email protected]>--- drivers/input/touchscreen/ads7846.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/input/touchscreen/ads7846.c +2
-1@@ -1288,7 +1288,8 @@ static int ads7846_probe(struct spi_device *spi)* may not. So we stick to very-portable 8 bit words, both RX and TX. */ spi->bits_per_word =8 ; - spi->mode =SPI_MODE_0 ; + spi->mode &= ~SPI_MODE_X_MASK ; + spi->mode |=SPI_MODE_0 ; err =spi_setup (spi);if (err <0 )return err;Signature · 1 line
2.28.0
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 2/2] Input: ads7846: do not overwrite spi->mode flags set by spi framework
In reply to Oleksij RempelQuoted 4 lines · Oleksij Rempel
Do not overwrite
spi->modeflags set by spi framework, otherwise the chip select polarity will get lost.Signed-off-by Oleksij Rempel <[email protected]>
Mark, could you please pick up this one through your tree as well? I do not believe that outstanding patches that I have in my queue for this driver will clash with it.
Thanks!
Quoted 21 lines
--- drivers/input/touchscreen/ads7846.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/input/touchscreen/ads7846.c +2
-1@@ -1288,7 +1288,8 @@ static int ads7846_probe(struct spi_device *spi)* may not. So we stick to very-portable 8 bit words, both RX and TX. */ spi->bits_per_word =8 ; - spi->mode =SPI_MODE_0 ; + spi->mode &= ~SPI_MODE_X_MASK ; + spi->mode |=SPI_MODE_0 ; err =spi_setup (spi);if (err <0 )return err;Signature · 1 line
2.28.0
Signature · 1 line
Dmitry
Mark Brown
maintainerQuoted 9 lines · Oleksij Rempel
changes v2:
- addSPI_MODE_X_MASKmacro
- ads7846: clearSPI_MODE_X_MASKbits to set driver specific mode.Oleksij Rempel (2):
spi: introduceSPI_MODE_X_MASKmacro
Input: ads7846: do not overwritespi->modeflags set by spi framework[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: introduce SPI_MODE_X_MASK macro
commit: 029b42d8519cef70c4fb5fcaccd08f1053ed2bf0
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Mark Brown
maintainerQuoted 9 lines · Oleksij Rempel
changes v2:
- addSPI_MODE_X_MASKmacro
- ads7846: clearSPI_MODE_X_MASKbits to set driver specific mode.Oleksij Rempel (2):
spi: introduceSPI_MODE_X_MASKmacro
Input: ads7846: do not overwritespi->modeflags set by spi framework[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] Input: ads7846: do not overwrite spi->mode flags set by spi framework
commit: 376ccca853fdb9959f7ac5185a428a9f91e71e86
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark