diff mbox

spi: omap2-mcspi: Do not configure the controller on each transfer unless needed

Message ID 1391354652-32092-1-git-send-email-stefan.sorensen@spectralink.com (mailing list archive)
State Accepted
Commit 2bd16e3e23d9df41592c6b257c59b6860a9cc3ea
Headers show

Commit Message

Stefan Sørensen Feb. 2, 2014, 3:24 p.m. UTC
spi_transfer->speed_hz and spi_transfer->bits_per_word used to only be set when
not using the default settings but are not set on every transfer, causing
omap2_mcspi_setup_transfer to be called on each transfer. This patch changes
the check to only call omap2_mcspi_setup_transfer if the settings needs to be
changed.

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
---
 drivers/spi/spi-omap2-mcspi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Mark Brown Feb. 3, 2014, 6:26 p.m. UTC | #1
On Sun, Feb 02, 2014 at 04:24:12PM +0100, Stefan Sørensen wrote:
> spi_transfer->speed_hz and spi_transfer->bits_per_word used to only be set when
> not using the default settings but are not set on every transfer, causing

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index a72127f..965539b 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1057,12 +1057,15 @@  static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
 			status = -EINVAL;
 			break;
 		}
-		if (par_override || t->speed_hz || t->bits_per_word) {
+		if (par_override ||
+		    (t->speed_hz != spi->max_speed_hz) ||
+		    (t->bits_per_word != spi->bits_per_word)) {
 			par_override = 1;
 			status = omap2_mcspi_setup_transfer(spi, t);
 			if (status < 0)
 				break;
-			if (!t->speed_hz && !t->bits_per_word)
+			if (t->speed_hz == spi->max_speed_hz &&
+			    t->bits_per_word == spi->bits_per_word)
 				par_override = 0;
 		}
 		if (cd && cd->cs_per_word) {