From patchwork Fri Jun 4 20:13:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Niebuhr X-Patchwork-Id: 104320 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o54KDjiD021431 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 4 Jun 2010 20:14:21 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OKdGy-0002GI-Ot; Fri, 04 Jun 2010 20:13:44 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.123] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OKdGx-0002G6-E5 for spi-devel-general@lists.sourceforge.net; Fri, 04 Jun 2010 20:13:43 +0000 Received-SPF: pass (sfi-mx-3.v28.ch3.sourceforge.com: domain of gmail.com designates 74.125.83.47 as permitted sender) client-ip=74.125.83.47; envelope-from=bniebuhr3@gmail.com; helo=mail-gw0-f47.google.com; Received: from mail-gw0-f47.google.com ([74.125.83.47]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1OKdGw-0002MD-HS for spi-devel-general@lists.sourceforge.net; Fri, 04 Jun 2010 20:13:43 +0000 Received: by gwb20 with SMTP id 20so210099gwb.34 for ; Fri, 04 Jun 2010 13:13:37 -0700 (PDT) Received: by 10.150.56.41 with SMTP id e41mr11550549yba.348.1275682417186; Fri, 04 Jun 2010 13:13:37 -0700 (PDT) Received: from localhost.localdomain (h197.252.190.173.static.ip.windstream.net [173.190.252.197]) by mx.google.com with ESMTPS id v1sm19842270ybh.23.2010.06.04.13.13.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 04 Jun 2010 13:13:36 -0700 (PDT) From: Brian Niebuhr To: spi-devel-general@lists.sourceforge.net Date: Fri, 4 Jun 2010 15:13:07 -0500 Message-Id: <1275682387-10681-1-git-send-email-bniebuhr@efjohnson.com> X-Mailer: git-send-email 1.6.3.3 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 DKIM_VERIFIED Domain Keys Identified Mail: signature passes verification 0.0 DKIM_SIGNED Domain Keys Identified Mail: message has a signature X-Headers-End: 1OKdGw-0002MD-HS Subject: [spi-devel-general] [PATCH] spi: reinitialize transfer parameters for every message X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 04 Jun 2010 20:14:25 +0000 (UTC) diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c index 5265330..8c0c0b8 100644 --- a/drivers/spi/spi_bitbang.c +++ b/drivers/spi/spi_bitbang.c @@ -259,7 +259,6 @@ static void bitbang_work(struct work_struct *work) struct spi_bitbang *bitbang = container_of(work, struct spi_bitbang, work); unsigned long flags; - int do_setup = -1; int (*setup_transfer)(struct spi_device *, struct spi_transfer *); @@ -275,6 +274,8 @@ static void bitbang_work(struct work_struct *work) unsigned tmp; unsigned cs_change; int status; + int do_setup = 1; + int restore_param = 0; m = container_of(bitbang->queue.next, struct spi_message, queue); @@ -295,10 +296,11 @@ static void bitbang_work(struct work_struct *work) list_for_each_entry (t, &m->transfers, transfer_list) { /* override speed or wordsize? */ - if (t->speed_hz || t->bits_per_word) + if (t->speed_hz || t->bits_per_word) { do_setup = 1; + restore_param = 1; + } - /* init (-1) or override (1) transfer params */ if (do_setup != 0) { if (!setup_transfer) { status = -ENOPROTOOPT; @@ -307,6 +309,7 @@ static void bitbang_work(struct work_struct *work) status = setup_transfer(spi, t); if (status < 0) break; + do_setup = 0; } /* set up default clock polarity, and activate chip; @@ -368,9 +371,8 @@ static void bitbang_work(struct work_struct *work) m->complete(m->context); /* restore speed and wordsize if it was overridden */ - if (do_setup == 1) + if (restore_param == 1) setup_transfer(spi, NULL); - do_setup = 0; /* normally deactivate chipselect ... unless no error and * cs_change has hinted that the next message will probably