Skip to content

Commit 990b11a

Browse files
committed
Merge tag 'spi-fix-v6.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fix from Mark Brown: "A fix adding missing validation that 8 bit I/O mode is actually supported for the specific device when attempting to use it. Anything that runs into this should already have been having problems, enforcing this should just make things safer and more obvious" * tag 'spi-fix-v6.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: Add check for 8-bit transfer with 8 IO mode support
2 parents 875dd23 + 7105052 commit 990b11a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/spi/spi.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4138,10 +4138,13 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
41384138
xfer->tx_nbits != SPI_NBITS_OCTAL)
41394139
return -EINVAL;
41404140
if ((xfer->tx_nbits == SPI_NBITS_DUAL) &&
4141-
!(spi->mode & (SPI_TX_DUAL | SPI_TX_QUAD)))
4141+
!(spi->mode & (SPI_TX_DUAL | SPI_TX_QUAD | SPI_TX_OCTAL)))
41424142
return -EINVAL;
41434143
if ((xfer->tx_nbits == SPI_NBITS_QUAD) &&
4144-
!(spi->mode & SPI_TX_QUAD))
4144+
!(spi->mode & (SPI_TX_QUAD | SPI_TX_OCTAL)))
4145+
return -EINVAL;
4146+
if ((xfer->tx_nbits == SPI_NBITS_OCTAL) &&
4147+
!(spi->mode & SPI_TX_OCTAL))
41454148
return -EINVAL;
41464149
}
41474150
/* Check transfer rx_nbits */
@@ -4154,10 +4157,13 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
41544157
xfer->rx_nbits != SPI_NBITS_OCTAL)
41554158
return -EINVAL;
41564159
if ((xfer->rx_nbits == SPI_NBITS_DUAL) &&
4157-
!(spi->mode & (SPI_RX_DUAL | SPI_RX_QUAD)))
4160+
!(spi->mode & (SPI_RX_DUAL | SPI_RX_QUAD | SPI_RX_OCTAL)))
41584161
return -EINVAL;
41594162
if ((xfer->rx_nbits == SPI_NBITS_QUAD) &&
4160-
!(spi->mode & SPI_RX_QUAD))
4163+
!(spi->mode & (SPI_RX_QUAD | SPI_RX_OCTAL)))
4164+
return -EINVAL;
4165+
if ((xfer->rx_nbits == SPI_NBITS_OCTAL) &&
4166+
!(spi->mode & SPI_RX_OCTAL))
41614167
return -EINVAL;
41624168
}
41634169

0 commit comments

Comments
 (0)