All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Pernamitta <pervivek@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: pervivek@gmail.com, Mark Brown <broonie@kernel.org>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] spi: spidev: Fix for reverting spi max speed value only on failure
Date: Sun,  2 Jun 2019 19:49:59 +0530	[thread overview]
Message-ID: <20190602141959.5616-1-pervivek@gmail.com> (raw)

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


             reply	other threads:[~2019-06-02 14:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-02 14:19 Vivek Pernamitta [this message]
2019-06-03 15:57 ` [PATCH] spi: spidev: Fix for reverting spi max speed value only on failure 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=20190602141959.5616-1-pervivek@gmail.com \
    --to=pervivek@gmail.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.