@@ -357,6 +357,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
357
357
int retval = 0 ;
358
358
struct spidev_data * spidev ;
359
359
struct spi_device * spi ;
360
+ struct spi_controller * ctlr ;
360
361
u32 tmp ;
361
362
unsigned n_ioc ;
362
363
struct spi_ioc_transfer * ioc ;
@@ -376,6 +377,8 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
376
377
return - ESHUTDOWN ;
377
378
}
378
379
380
+ ctlr = spi -> controller ;
381
+
379
382
/* use the buffer lock here for triple duty:
380
383
* - prevent I/O (from us) so calling spi_setup() is safe;
381
384
* - prevent concurrent SPI_IOC_WR_* from morphing
@@ -388,22 +391,15 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
388
391
/* read requests */
389
392
case SPI_IOC_RD_MODE :
390
393
case SPI_IOC_RD_MODE32 :
391
- tmp = spi -> mode ;
392
-
393
- {
394
- struct spi_controller * ctlr = spi -> controller ;
394
+ tmp = spi -> mode & SPI_MODE_MASK ;
395
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 && spi_get_csgpiod (spi , 0 ))
397
+ tmp &= ~SPI_CS_HIGH ;
400
398
401
399
if (cmd == SPI_IOC_RD_MODE )
402
- retval = put_user (tmp & SPI_MODE_MASK ,
403
- (__u8 __user * )arg );
400
+ retval = put_user (tmp , (__u8 __user * )arg );
404
401
else
405
- retval = put_user (tmp & SPI_MODE_MASK ,
406
- (__u32 __user * )arg );
402
+ retval = put_user (tmp , (__u32 __user * )arg );
407
403
break ;
408
404
case SPI_IOC_RD_LSB_FIRST :
409
405
retval = put_user ((spi -> mode & SPI_LSB_FIRST ) ? 1 : 0 ,
@@ -424,16 +420,14 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
424
420
else
425
421
retval = get_user (tmp , (u32 __user * )arg );
426
422
if (retval == 0 ) {
427
- struct spi_controller * ctlr = spi -> controller ;
428
423
u32 save = spi -> mode ;
429
424
430
425
if (tmp & ~SPI_MODE_MASK ) {
431
426
retval = - EINVAL ;
432
427
break ;
433
428
}
434
429
435
- if (ctlr -> use_gpio_descriptors && ctlr -> cs_gpiods &&
436
- ctlr -> cs_gpiods [spi_get_chipselect (spi , 0 )])
430
+ if (ctlr -> use_gpio_descriptors && spi_get_csgpiod (spi , 0 ))
437
431
tmp |= SPI_CS_HIGH ;
438
432
439
433
tmp |= spi -> mode & ~SPI_MODE_MASK ;
0 commit comments