From patchwork Fri Jul 24 05:37:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars Persson X-Patchwork-Id: 6857401 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C3E8B9F380 for ; Fri, 24 Jul 2015 05:37:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5F4120573 for ; Fri, 24 Jul 2015 05:37:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB5652056D for ; Fri, 24 Jul 2015 05:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751336AbbGXFhj (ORCPT ); Fri, 24 Jul 2015 01:37:39 -0400 Received: from bes.se.axis.com ([195.60.68.10]:56931 "EHLO bes.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751053AbbGXFhi (ORCPT ); Fri, 24 Jul 2015 01:37:38 -0400 Received: from localhost (localhost [127.0.0.1]) by bes.se.axis.com (Postfix) with ESMTP id 44AA42E0C7; Fri, 24 Jul 2015 07:37:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bes.se.axis.com Received: from bes.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bes.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id ErrwHslakJqq; Fri, 24 Jul 2015 07:37:36 +0200 (CEST) Received: from boulder.se.axis.com (boulder.se.axis.com [10.0.2.104]) by bes.se.axis.com (Postfix) with ESMTP id 9A8B22E0B0; Fri, 24 Jul 2015 07:37:36 +0200 (CEST) Received: from boulder.se.axis.com (localhost [127.0.0.1]) by postfix.imss71 (Postfix) with ESMTP id 5826C144E; Fri, 24 Jul 2015 07:37:36 +0200 (CEST) Received: from thoth.se.axis.com (thoth.se.axis.com [10.0.2.173]) by boulder.se.axis.com (Postfix) with ESMTP id 4B17F140A; Fri, 24 Jul 2015 07:37:36 +0200 (CEST) Received: from lnxlarper.se.axis.com (lnxlarper.se.axis.com [10.88.41.1]) by thoth.se.axis.com (Postfix) with ESMTP id 4892934005; Fri, 24 Jul 2015 07:37:36 +0200 (CEST) Received: by lnxlarper.se.axis.com (Postfix, from userid 20456) id 267998014D; Fri, 24 Jul 2015 07:37:22 +0200 (CEST) From: Lars Persson To: linux-spi@vger.kernel.org, broonie@kernel.org, m.grzeschik@pengutronix.de Cc: Lars Persson Subject: [PATCH] Revert "spi: bitbang: only toggle bitchanges" Date: Fri, 24 Jul 2015 07:37:16 +0200 Message-Id: <1437716236-12715-1-git-send-email-larper@axis.com> X-Mailer: git-send-email 2.1.4 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit 232a5adc5199 ("spi: bitbang: only toggle bitchanges") because it breaks bitbanged SPI on our MIPS system. I found two problems with the patch: - oldbit must initially be computed from bit position 7, 15 or 31 of word depending on the value of bits. - The optimization also does not eliminate consecutive ones because the compare of 1<<31 and 1 will be false (a bool only takes values 0 or 1). Signed-off-by: Lars Persson --- drivers/spi/spi-bitbang-txrx.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-bitbang-txrx.h b/drivers/spi/spi-bitbang-txrx.h index 06b34e5..c616e41 100644 --- a/drivers/spi/spi-bitbang-txrx.h +++ b/drivers/spi/spi-bitbang-txrx.h @@ -49,17 +49,12 @@ bitbang_txrx_be_cpha0(struct spi_device *spi, { /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */ - bool oldbit = !(word & 1); /* clock starts at inactive polarity */ for (word <<= (32 - bits); likely(bits); bits--) { /* setup MSB (to slave) on trailing edge */ - if ((flags & SPI_MASTER_NO_TX) == 0) { - if ((word & (1 << 31)) != oldbit) { - setmosi(spi, word & (1 << 31)); - oldbit = word & (1 << 31); - } - } + if ((flags & SPI_MASTER_NO_TX) == 0) + setmosi(spi, word & (1 << 31)); spidelay(nsecs); /* T(setup) */ setsck(spi, !cpol); @@ -81,18 +76,13 @@ bitbang_txrx_be_cpha1(struct spi_device *spi, { /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */ - bool oldbit = !(word & (1 << 31)); /* clock starts at inactive polarity */ for (word <<= (32 - bits); likely(bits); bits--) { /* setup MSB (to slave) on leading edge */ setsck(spi, !cpol); - if ((flags & SPI_MASTER_NO_TX) == 0) { - if ((word & (1 << 31)) != oldbit) { - setmosi(spi, word & (1 << 31)); - oldbit = word & (1 << 31); - } - } + if ((flags & SPI_MASTER_NO_TX) == 0) + setmosi(spi, word & (1 << 31)); spidelay(nsecs); /* T(setup) */ setsck(spi, cpol);