Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752060AbdHPLJS (ORCPT ); Wed, 16 Aug 2017 07:09:18 -0400 Received: from smtp.transmode.se ([31.15.61.139]:65047 "EHLO smtp.transmode.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbdHPLJR (ORCPT ); Wed, 16 Aug 2017 07:09:17 -0400 X-Greylist: delayed 394 seconds by postgrey-1.27 at vger.kernel.org; Wed, 16 Aug 2017 07:09:16 EDT From: Joakim Tjernlund To: linux-kernel@vger.kernel.org, Scott Wood Cc: Joakim Tjernlund Subject: [PATCH] spi-fsl-spi: Align CS behaviour for last SPI msg Date: Wed, 16 Aug 2017 13:02:14 +0200 Message-Id: <20170816110214.31089-1-joakim.tjernlund@infinera.com> X-Mailer: git-send-email 2.13.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1341 Lines: 49 According to spi.h cs_change can be used to leave the CS active until next SPI transfer(paragraph ii). Adjust driver to comply with (ii). Signed-off-by: Joakim Tjernlund --- drivers/spi/spi-fsl-spi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 061c1f38bf46..9a6cb26680a9 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -358,6 +358,7 @@ static int fsl_spi_do_one_msg(struct spi_master *master, { struct spi_device *spi = m->spi; struct spi_transfer *t, *first; + bool keep_cs = false; unsigned int cs_change; const int nsecs = 50; int status; @@ -401,16 +402,21 @@ static int fsl_spi_do_one_msg(struct spi_master *master, udelay(t->delay_usecs); if (cs_change) { - ndelay(nsecs); - fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE); - ndelay(nsecs); + if (list_is_last(&t->transfer_list, + &m->transfers)) { + keep_cs = true; + } else { + ndelay(nsecs); + fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE); + ndelay(nsecs); + } } } m->status = status; spi_finalize_current_message(master); - if (status || !cs_change) { + if (status || !keep_cs) { ndelay(nsecs); fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE); } -- 2.13.0