From: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
To: "linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>,
Oleksandr Suvorov <cryosay@gmail.com>,
Marcel Ziswiler <marcel.ziswiler@toradex.com>,
Igor Opanyuk <igor.opanyuk@toradex.com>,
Philippe Schenker <philippe.schenker@toradex.com>,
Mark Brown <broonie@kernel.org>
Subject: [PATCH 2/2] spi: spidev: fix a max speed setting
Date: Thu, 20 Feb 2020 14:11:51 +0000 [thread overview]
Message-ID: <20200220141143.3902922-3-oleksandr.suvorov@toradex.com> (raw)
In-Reply-To: <20200220141143.3902922-1-oleksandr.suvorov@toradex.com>
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@toradex.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
next prev parent reply other threads:[~2020-02-20 14:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-20 14:11 [PATCH 0/2] trivial fixes for fsl-spi and spidev Oleksandr Suvorov
2020-02-20 14:11 ` Oleksandr Suvorov [this message]
[not found] ` <20200220141143.3902922-3-oleksandr.suvorov-2KBjVHiyJgBBDgjK7y7TUQ@public.gmane.org>
2020-02-20 18:42 ` [PATCH 2/2] spi: spidev: fix a max speed setting Mark Brown
[not found] ` <20200220184201.GE3926-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2020-02-21 12:43 ` Oleksandr Suvorov
[not found] ` <20200220141143.3902922-1-oleksandr.suvorov-2KBjVHiyJgBBDgjK7y7TUQ@public.gmane.org>
2020-02-20 14:11 ` [PATCH 1/2] spi: fsl-lpspi: remove unneeded array Oleksandr Suvorov
[not found] ` <20200220141143.3902922-2-oleksandr.suvorov-2KBjVHiyJgBBDgjK7y7TUQ@public.gmane.org>
2020-03-03 17:08 ` Applied "spi: fsl-lpspi: remove unneeded array" to the spi tree Mark Brown
2020-02-20 16:47 ` [PATCH 0/2] trivial fixes for fsl-spi and spidev Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200220141143.3902922-3-oleksandr.suvorov@toradex.com \
--to=oleksandr.suvorov@toradex.com \
--cc=broonie@kernel.org \
--cc=cryosay@gmail.com \
--cc=igor.opanyuk@toradex.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=marcel.ziswiler@toradex.com \
--cc=philippe.schenker@toradex.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).