Skip to content

Commit 764246c

Browse files
andy-shevbroonie
authored andcommitted
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 <[email protected]> Reviewed-by: Lukas Wunner <[email protected]> Reviewed-by: Alexander Sverdlin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 193a7f9 commit 764246c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/spi/spidev.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,17 +391,15 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
391391
/* read requests */
392392
case SPI_IOC_RD_MODE:
393393
case SPI_IOC_RD_MODE32:
394-
tmp = spi->mode;
394+
tmp = spi->mode & SPI_MODE_MASK;
395395

396396
if (ctlr->use_gpio_descriptors && spi_get_csgpiod(spi, 0))
397397
tmp &= ~SPI_CS_HIGH;
398398

399399
if (cmd == SPI_IOC_RD_MODE)
400-
retval = put_user(tmp & SPI_MODE_MASK,
401-
(__u8 __user *)arg);
400+
retval = put_user(tmp, (__u8 __user *)arg);
402401
else
403-
retval = put_user(tmp & SPI_MODE_MASK,
404-
(__u32 __user *)arg);
402+
retval = put_user(tmp, (__u32 __user *)arg);
405403
break;
406404
case SPI_IOC_RD_LSB_FIRST:
407405
retval = put_user((spi->mode & SPI_LSB_FIRST) ? 1 : 0,

0 commit comments

Comments
 (0)