[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200220141143.3902922-3-oleksandr.suvorov@toradex.com>
Date: Thu, 20 Feb 2020 14:11:51 +0000
From: Oleksandr Suvorov <oleksandr.suvorov@...adex.com>
To: "linux-spi@...r.kernel.org" <linux-spi@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: Oleksandr Suvorov <oleksandr.suvorov@...adex.com>,
Oleksandr Suvorov <cryosay@...il.com>,
Marcel Ziswiler <marcel.ziswiler@...adex.com>,
Igor Opanyuk <igor.opanyuk@...adex.com>,
Philippe Schenker <philippe.schenker@...adex.com>,
Mark Brown <broonie@...nel.org>
Subject: [PATCH 2/2] spi: spidev: fix a max speed setting
SPI_IOC_WR_MAX_SPEED_HZ command always sets spi->max_speed_hz
to the initial value come from DT.
It leads to set a wrong max speed with IOCTL call.
Fix the logic of a max speed assignment.
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@...adex.com>
---
drivers/spi/spidev.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 1e217e3e9486..b9b3ac70eb18 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -449,11 +449,13 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
spi->max_speed_hz = tmp;
retval = spi_setup(spi);
- if (retval >= 0)
+ if (retval) {
+ spi->max_speed_hz = save;
+ } else {
spidev->speed_hz = tmp;
- else
- dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
- spi->max_speed_hz = save;
+ dev_dbg(&spi->dev, "%d Hz (max)\n",
+ spidev->speed_hz);
+ }
}
break;
--
2.24.1
Powered by blists - more mailing lists