* [PATCH] spi: spidev: Fix for reverting spi max speed value only on failure
@ 2019-06-02 14:19 Vivek Pernamitta
2019-06-03 15:57 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Vivek Pernamitta @ 2019-06-02 14:19 UTC (permalink / raw)
Cc: pervivek, Mark Brown, linux-spi, linux-kernel
When user space application request for change in spi clock
using ioctl, current value is taken back-up and new value is
assigned to spi->max_speed_hz, then spi_setup() function is
called with new value. If spi_setup() function fails, it needs
reverting to old spi_max_speed value only in failure condition.
Signed-off-by: Vivek Pernamitta <pervivek@gmail.com>
---
drivers/spi/spidev.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 30498cf25f3b..70382b642f37 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -458,9 +458,10 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
retval = spi_setup(spi);
if (retval >= 0)
spidev->speed_hz = tmp;
- else
+ else {
dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
- spi->max_speed_hz = save;
+ spi->max_speed_hz = save;
+ }
}
break;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] spi: spidev: Fix for reverting spi max speed value only on failure
2019-06-02 14:19 [PATCH] spi: spidev: Fix for reverting spi max speed value only on failure Vivek Pernamitta
@ 2019-06-03 15:57 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2019-06-03 15:57 UTC (permalink / raw)
To: Vivek Pernamitta; +Cc: linux-spi, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 706 bytes --]
On Sun, Jun 02, 2019 at 07:49:59PM +0530, Vivek Pernamitta wrote:
> When user space application request for change in spi clock
> using ioctl, current value is taken back-up and new value is
> assigned to spi->max_speed_hz, then spi_setup() function is
> called with new value. If spi_setup() function fails, it needs
> reverting to old spi_max_speed value only in failure condition.
The current behaviour is intentional, we're not modifying max_speed_hz
so we can continue to enforce the kernel limit no matter what userspace
asked for - actually looking at the code we should probably have an
explicit error check in there to reject attempts to raise it here, not
sure why we're not doing that already.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-03 15:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-02 14:19 [PATCH] spi: spidev: Fix for reverting spi max speed value only on failure Vivek Pernamitta
2019-06-03 15:57 ` Mark Brown
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).