Commit 764246c7 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mark Brown

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLukas Wunner <lukas@wunner.de>
Reviewed-by: default avatarAlexander Sverdlin <alexander.sverdlin@siemens.com>
Link: https://lore.kernel.org/r/20230824162209.2890440-4-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 193a7f9e
...@@ -391,17 +391,15 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -391,17 +391,15 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/* read requests */ /* read requests */
case SPI_IOC_RD_MODE: case SPI_IOC_RD_MODE:
case SPI_IOC_RD_MODE32: case SPI_IOC_RD_MODE32:
tmp = spi->mode; tmp = spi->mode & SPI_MODE_MASK;
if (ctlr->use_gpio_descriptors && spi_get_csgpiod(spi, 0)) if (ctlr->use_gpio_descriptors && spi_get_csgpiod(spi, 0))
tmp &= ~SPI_CS_HIGH; tmp &= ~SPI_CS_HIGH;
if (cmd == SPI_IOC_RD_MODE) if (cmd == SPI_IOC_RD_MODE)
retval = put_user(tmp & SPI_MODE_MASK, retval = put_user(tmp, (__u8 __user *)arg);
(__u8 __user *)arg);
else else
retval = put_user(tmp & SPI_MODE_MASK, retval = put_user(tmp, (__u32 __user *)arg);
(__u32 __user *)arg);
break; break;
case SPI_IOC_RD_LSB_FIRST: case SPI_IOC_RD_LSB_FIRST:
retval = put_user((spi->mode & SPI_LSB_FIRST) ? 1 : 0, retval = put_user((spi->mode & SPI_LSB_FIRST) ? 1 : 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment