Skip to content

Commit 12c8d7a

Browse files
andy-shevbroonie
authored andcommitted
spidev: Decrease indentation level in spidev_ioctl() SPI_IOC_RD_MODE*
Instead of defining a local controller variable inside an indented block, move the definition to the top of spidev_ioctl() and reuse it in the SPI_IOC_RD_MODE* and SPI_IOC_WR_MODE* cases. This drops unneeded indentation and reduces amount of LoCs. Signed-off-by: Andy Shevchenko <[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 2d98bda commit 12c8d7a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/spi/spidev.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
357357
int retval = 0;
358358
struct spidev_data *spidev;
359359
struct spi_device *spi;
360+
struct spi_controller *ctlr;
360361
u32 tmp;
361362
unsigned n_ioc;
362363
struct spi_ioc_transfer *ioc;
@@ -376,6 +377,8 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
376377
return -ESHUTDOWN;
377378
}
378379

380+
ctlr = spi->controller;
381+
379382
/* use the buffer lock here for triple duty:
380383
* - prevent I/O (from us) so calling spi_setup() is safe;
381384
* - prevent concurrent SPI_IOC_WR_* from morphing
@@ -390,13 +393,9 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
390393
case SPI_IOC_RD_MODE32:
391394
tmp = spi->mode;
392395

393-
{
394-
struct spi_controller *ctlr = spi->controller;
395-
396-
if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
397-
ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
398-
tmp &= ~SPI_CS_HIGH;
399-
}
396+
if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
397+
ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
398+
tmp &= ~SPI_CS_HIGH;
400399

401400
if (cmd == SPI_IOC_RD_MODE)
402401
retval = put_user(tmp & SPI_MODE_MASK,
@@ -424,7 +423,6 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
424423
else
425424
retval = get_user(tmp, (u32 __user *)arg);
426425
if (retval == 0) {
427-
struct spi_controller *ctlr = spi->controller;
428426
u32 save = spi->mode;
429427

430428
if (tmp & ~SPI_MODE_MASK) {

0 commit comments

Comments
 (0)