[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f68cdc846df640b7423e91dd59fef4297de10059.camel@siemens.com>
Date: Fri, 25 Aug 2023 07:17:34 +0000
From: "Sverdlin, Alexander" <alexander.sverdlin@...mens.com>
To: "linux-spi@...r.kernel.org" <linux-spi@...r.kernel.org>,
"andriy.shevchenko@...ux.intel.com"
<andriy.shevchenko@...ux.intel.com>,
"broonie@...nel.org" <broonie@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1 1/3] spidev: Decrease indentation level in
spidev_ioctl() SPI_IOC_RD_MODE*
Hi!
On Thu, 2023-08-24 at 19:22 +0300, Andy Shevchenko wrote:
> 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 <andriy.shevchenko@...ux.intel.com>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@...mens.com>
> ---
> drivers/spi/spidev.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
> index d13dc15cc191..dc516f0ca71f 100644
> --- a/drivers/spi/spidev.c
> +++ b/drivers/spi/spidev.c
> @@ -357,6 +357,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> int retval = 0;
> struct spidev_data *spidev;
> struct spi_device *spi;
> + struct spi_controller *ctlr;
> u32 tmp;
> unsigned n_ioc;
> struct spi_ioc_transfer *ioc;
> @@ -376,6 +377,8 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> return -ESHUTDOWN;
> }
>
> + ctlr = spi->controller;
> +
> /* use the buffer lock here for triple duty:
> * - prevent I/O (from us) so calling spi_setup() is safe;
> * - prevent concurrent SPI_IOC_WR_* from morphing
> @@ -390,13 +393,9 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> case SPI_IOC_RD_MODE32:
> tmp = spi->mode;
>
> - {
> - struct spi_controller *ctlr = spi->controller;
> -
> - if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
> - ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
> - tmp &= ~SPI_CS_HIGH;
> - }
> + if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
> + ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
> + tmp &= ~SPI_CS_HIGH;
>
> if (cmd == SPI_IOC_RD_MODE)
> retval = put_user(tmp & SPI_MODE_MASK,
> @@ -424,7 +423,6 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> else
> retval = get_user(tmp, (u32 __user *)arg);
> if (retval == 0) {
> - struct spi_controller *ctlr = spi->controller;
> u32 save = spi->mode;
>
> if (tmp & ~SPI_MODE_MASK) {
--
Alexander Sverdlin
Siemens AG
www.siemens.com
Powered by blists - more mailing lists