diff mbox series

[v1,2/3] spidev: Switch to use spi_get_csgpiod()

Message ID 20230824162209.2890440-3-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Commit 193a7f9e1a78f69c913bb26ca4500f6edad1e8ff
Headers show
Series spidev: A few cleanups | expand

Commit Message

Andy Shevchenko Aug. 24, 2023, 4:22 p.m. UTC
spidev_ioctl() checks if there is an SPI chip select is driven by GPIO.
Instead of current code, we can call spi_get_csgpiod().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spidev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

A. Sverdlin Aug. 25, 2023, 7:17 a.m. UTC | #1
Hi!

On Thu, 2023-08-24 at 19:22 +0300, Andy Shevchenko wrote:
> spidev_ioctl() checks if there is an SPI chip select is driven by GPIO.
                                                     ^^^ ?

> Instead of current code, we can call spi_get_csgpiod().
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>

> ---
>  drivers/spi/spidev.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
> index dc516f0ca71f..e324b42c658c 100644
> --- a/drivers/spi/spidev.c
> +++ b/drivers/spi/spidev.c
> @@ -393,8 +393,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>         case SPI_IOC_RD_MODE32:
>                 tmp = spi->mode;
>  
> -               if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
> -                   ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
> +               if (ctlr->use_gpio_descriptors && spi_get_csgpiod(spi, 0))
>                         tmp &= ~SPI_CS_HIGH;
>  
>                 if (cmd == SPI_IOC_RD_MODE)
> @@ -430,8 +429,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>                                 break;
>                         }
>  
> -                       if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
> -                           ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
> +                       if (ctlr->use_gpio_descriptors && spi_get_csgpiod(spi, 0))
>                                 tmp |= SPI_CS_HIGH;
>  
>                         tmp |= spi->mode & ~SPI_MODE_MASK;
diff mbox series

Patch

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index dc516f0ca71f..e324b42c658c 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -393,8 +393,7 @@  spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	case SPI_IOC_RD_MODE32:
 		tmp = spi->mode;
 
-		if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
-		    ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
+		if (ctlr->use_gpio_descriptors && spi_get_csgpiod(spi, 0))
 			tmp &= ~SPI_CS_HIGH;
 
 		if (cmd == SPI_IOC_RD_MODE)
@@ -430,8 +429,7 @@  spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 				break;
 			}
 
-			if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
-			    ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
+			if (ctlr->use_gpio_descriptors && spi_get_csgpiod(spi, 0))
 				tmp |= SPI_CS_HIGH;
 
 			tmp |= spi->mode & ~SPI_MODE_MASK;