aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@linux-m68k.org>2014-02-25 05:40:16 -0500
committerMark Brown <broonie@linaro.org>2014-02-26 23:50:33 -0500
commite6456186cae76f80446ba911f77eb2f85d3d927e (patch)
tree0dc81d3d47f8c7e7611c3fdb66068cd6ee8d6944 /drivers/spi
parent925d16a209b40a3e7202a4f867991fb608834d36 (diff)
spi: spidev: Restore all SPI mode flags on ioctl failure
In commit f477b7fb13df2b843997559ff34e87d054ba6538 ("spi: DUAL and QUAD support"), spi_device.mode was enlarged from 8 to 16 bits. However, the spidev code still only saved 8 bits of data. If a spidev SPI_IOC_WR_MODE or SPI_IOC_WR_LSB_FIRST request failed, only the lower 8 bits of the SPI mode were restored, inadvertently clearing the upper 8 bits, possibly disabling Quad or Dual SPI transfers for the device. Save up to 32 bits to fix this. For SPI_IOC_WR_MODE this is probably not so important, as it doesn't allow setting Quad or Dual mode anyway, but SPI_IOC_WR_LSB_FIRST is used to just set or clear a single bit. Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spidev.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index d7c6e36021e8..2abc0f5a82be 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -374,7 +374,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
374 case SPI_IOC_WR_MODE: 374 case SPI_IOC_WR_MODE:
375 retval = __get_user(tmp, (u8 __user *)arg); 375 retval = __get_user(tmp, (u8 __user *)arg);
376 if (retval == 0) { 376 if (retval == 0) {
377 u8 save = spi->mode; 377 u32 save = spi->mode;
378 378
379 if (tmp & ~SPI_MODE_MASK) { 379 if (tmp & ~SPI_MODE_MASK) {
380 retval = -EINVAL; 380 retval = -EINVAL;
@@ -393,7 +393,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
393 case SPI_IOC_WR_LSB_FIRST: 393 case SPI_IOC_WR_LSB_FIRST:
394 retval = __get_user(tmp, (__u8 __user *)arg); 394 retval = __get_user(tmp, (__u8 __user *)arg);
395 if (retval == 0) { 395 if (retval == 0) {
396 u8 save = spi->mode; 396 u32 save = spi->mode;
397 397
398 if (tmp) 398 if (tmp)
399 spi->mode |= SPI_LSB_FIRST; 399 spi->mode |= SPI_LSB_FIRST;