From patchwork Sun Mar 30 00:27:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 3909621 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06EE8BF540 for ; Sun, 30 Mar 2014 00:28:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2ED6C2039C for ; Sun, 30 Mar 2014 00:28:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 118ED20397 for ; Sun, 30 Mar 2014 00:28:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752554AbaC3A2D (ORCPT ); Sat, 29 Mar 2014 20:28:03 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:48837 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752552AbaC3A2C (ORCPT ); Sat, 29 Mar 2014 20:28:02 -0400 Received: from cpc12-camd15-2-0-cust251.20-2.cable.virginm.net ([82.45.252.252] helo=finisterre) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1WU3bO-0004cX-9r; Sun, 30 Mar 2014 00:27:58 +0000 Received: from broonie by finisterre with local (Exim 4.82) (envelope-from ) id 1WU3bF-0007Wj-TL; Sun, 30 Mar 2014 00:27:45 +0000 From: Mark Brown To: Gerhard Sittig Cc: linux-spi@vger.kernel.org, linaro-kernel@lists.linaro.org, Mark Brown Date: Sun, 30 Mar 2014 00:27:45 +0000 Message-Id: <1396139265-28900-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 1.9.1 X-SA-Exim-Connect-IP: 82.45.252.252 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Subject: [PATCH] spi: Fix handling of cs_change in core implementation X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mark Brown The core implementation of cs_change didn't follow the documentation which says that cs_change in the middle of the transfer means to briefly deassert chip select, instead it followed buggy drivers which change the polarity of chip select. Use a delay of 10us between deassert and reassert simply from pulling numbers out of a hat. Reported-by: Gerhard Sittig Signed-off-by: Mark Brown --- Compile tested only. drivers/spi/spi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 121c43b..4eb9bf0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -754,7 +754,6 @@ static int spi_transfer_one_message(struct spi_master *master, struct spi_message *msg) { struct spi_transfer *xfer; - bool cur_cs = true; bool keep_cs = false; int ret = 0; int ms = 1; @@ -800,8 +799,9 @@ static int spi_transfer_one_message(struct spi_master *master, &msg->transfers)) { keep_cs = true; } else { - cur_cs = !cur_cs; - spi_set_cs(msg->spi, cur_cs); + spi_set_cs(msg->spi, false); + udelay(10); + spi_set_cs(msg->spi, true); } }