Skip to contentSkip to conversation

SPI/ Input: ads7846: properly handle spi->mode flags

PATCH In review Oleksij Rempel 3 participants 7 messages Oct 27, 2020 – Nov 12, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 99380c0825db..8097f27702f3 100644
@@ -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
#2 lore raw

PATCH v2 2/2 Input: ads7846: do not overwrite spi->mode flags set by spi framework

In reply to Oleksij Rempel

Do 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
index 8fd7fc39c4fd..f2dc2c8ab5ec 100644
@@ -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
#3 lore raw

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->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
index 8fd7fc39c4fd..f2dc2c8ab5ec 100644
@@ -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 |
maintainer Acked-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] Input: ads7846: do not overwrite spi->mode flags set by spi framework

In reply to Oleksij Rempel
Quoted 4 lines · Oleksij Rempel

Do not overwrite spi->mode flags set by spi framework, otherwise the chip select polarity will get lost.

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
index 8fd7fc39c4fd..f2dc2c8ab5ec 100644
@@ -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
maintainer
#5 lore raw
In reply to Oleksij Rempel
Quoted 9 lines · Oleksij Rempel

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

[...]

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

maintainer
#6 lore raw
In reply to Oleksij Rempel
Quoted 9 lines · Oleksij Rempel

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

[...]

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