]> git.hungrycats.org Git - linux/commitdiff
spi: Fix OCTAL mode support
authorPatrice Chotard <patrice.chotard@foss.st.com>
Tue, 18 Jun 2024 13:29:51 +0000 (15:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2024 07:53:29 +0000 (09:53 +0200)
[ Upstream commit d6a711a898672dd873aab3844f754a3ca40723a5 ]

Add OCTAL mode support.
Issue detected using "--octal" spidev_test's option.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Link: https://msgid.link/r/20240618132951.2743935-4-patrice.chotard@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi.c
include/linux/spi/spi.h

index 9304fd03bf764a7f2c7c1dcf6e4694b739576472..fcc39523d68575917399c536d79aa7de7c4b9be0 100644 (file)
@@ -4152,7 +4152,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
                                return -EINVAL;
                        if (xfer->tx_nbits != SPI_NBITS_SINGLE &&
                                xfer->tx_nbits != SPI_NBITS_DUAL &&
-                               xfer->tx_nbits != SPI_NBITS_QUAD)
+                               xfer->tx_nbits != SPI_NBITS_QUAD &&
+                               xfer->tx_nbits != SPI_NBITS_OCTAL)
                                return -EINVAL;
                        if ((xfer->tx_nbits == SPI_NBITS_DUAL) &&
                                !(spi->mode & (SPI_TX_DUAL | SPI_TX_QUAD)))
@@ -4167,7 +4168,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
                                return -EINVAL;
                        if (xfer->rx_nbits != SPI_NBITS_SINGLE &&
                                xfer->rx_nbits != SPI_NBITS_DUAL &&
-                               xfer->rx_nbits != SPI_NBITS_QUAD)
+                               xfer->rx_nbits != SPI_NBITS_QUAD &&
+                               xfer->rx_nbits != SPI_NBITS_OCTAL)
                                return -EINVAL;
                        if ((xfer->rx_nbits == SPI_NBITS_DUAL) &&
                                !(spi->mode & (SPI_RX_DUAL | SPI_RX_QUAD)))
index 64a4deb18dd007e8731ae645c3a4891c2849d299..afe6631da1bc65a967d24ae86451b45758fc657a 100644 (file)
@@ -1089,12 +1089,13 @@ struct spi_transfer {
        unsigned        dummy_data:1;
        unsigned        cs_off:1;
        unsigned        cs_change:1;
-       unsigned        tx_nbits:3;
-       unsigned        rx_nbits:3;
+       unsigned        tx_nbits:4;
+       unsigned        rx_nbits:4;
        unsigned        timestamped:1;
 #define        SPI_NBITS_SINGLE        0x01 /* 1-bit transfer */
 #define        SPI_NBITS_DUAL          0x02 /* 2-bit transfer */
 #define        SPI_NBITS_QUAD          0x04 /* 4-bit transfer */
+#define        SPI_NBITS_OCTAL 0x08 /* 8-bit transfer */
        u8              bits_per_word;
        struct spi_delay        delay;
        struct spi_delay        cs_change_delay;