summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-08-24 18:22:09 +0200
committerMark Brown <broonie@kernel.org>2023-09-11 02:31:51 +0200
commit764246c7feda01f46b1a243cfa15ad5627874ef9 (patch)
tree1ae5a79e6eeea21d25cf02bccb9837c7430f4b71
parentspidev: Switch to use spi_get_csgpiod() (diff)
downloadlinux-764246c7feda01f46b1a243cfa15ad5627874ef9.tar.xz
linux-764246c7feda01f46b1a243cfa15ad5627874ef9.zip
spidev: Simplify SPI_IOC_RD_MODE* cases in spidev_ioctl()
The temporary variable tmp is not used outside of the SPI_IOC_RD_MODE* cases, hence we can optimize its use. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com> Link: https://lore.kernel.org/r/20230824162209.2890440-4-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spidev.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index e324b42c658c..c5450217528b 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -391,17 +391,15 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* read requests */
case SPI_IOC_RD_MODE:
case SPI_IOC_RD_MODE32:
- tmp = spi->mode;
+ tmp = spi->mode & SPI_MODE_MASK;
if (ctlr->use_gpio_descriptors && spi_get_csgpiod(spi, 0))
tmp &= ~SPI_CS_HIGH;
if (cmd == SPI_IOC_RD_MODE)
- retval = put_user(tmp & SPI_MODE_MASK,
- (__u8 __user *)arg);
+ retval = put_user(tmp, (__u8 __user *)arg);
else
- retval = put_user(tmp & SPI_MODE_MASK,
- (__u32 __user *)arg);
+ retval = put_user(tmp, (__u32 __user *)arg);
break;
case SPI_IOC_RD_LSB_FIRST:
retval = put_user((spi->mode & SPI_LSB_FIRST) ? 1 : 0,