From patchwork Wed Nov 25 08:26:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 62721 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAP8WZDA016384 for ; Wed, 25 Nov 2009 08:32:36 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NDDHr-000695-PU; Wed, 25 Nov 2009 08:31:43 +0000 Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.121] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NDDHq-00068r-DA for spi-devel-general@lists.sourceforge.net; Wed, 25 Nov 2009 08:31:42 +0000 Received-SPF: pass (sfi-mx-1.v28.ch3.sourceforge.com: domain of gmail.com designates 209.85.217.223 as permitted sender) client-ip=209.85.217.223; envelope-from=magnus.damm@gmail.com; helo=mail-gx0-f223.google.com; Received: from mail-gx0-f223.google.com ([209.85.217.223]) by sfi-mx-1.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1NDDHi-0003EM-5C for spi-devel-general@lists.sourceforge.net; Wed, 25 Nov 2009 08:31:42 +0000 Received: by gxk23 with SMTP id 23so8417288gxk.2 for ; Wed, 25 Nov 2009 00:31:28 -0800 (PST) Received: by 10.90.150.17 with SMTP id x17mr2215042agd.57.1259137888819; Wed, 25 Nov 2009 00:31:28 -0800 (PST) Received: from rxone.opensource.se (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id 4sm2783543yxd.34.2009.11.25.00.31.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 25 Nov 2009 00:31:28 -0800 (PST) From: Magnus Damm To: spi-devel-general@lists.sourceforge.net Date: Wed, 25 Nov 2009 17:26:03 +0900 Message-Id: <20091125082603.25618.57438.sendpatchset@rxone.opensource.se> X-Spam-Score: -2.4 (--) 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 -0.9 AWL AWL: From: address is in the auto white-list X-Headers-End: 1NDDHi-0003EM-5C Cc: akpm@linux-foundation.org, dbrownell@users.sourceforge.net, Magnus Damm , linux-kernel@vger.kernel.org Subject: [spi-devel-general] [PATCH] spi: Allow using spi_bitbang_setup() with custom txrx_bufs() 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 --- 0001/drivers/spi/spi_bitbang.c +++ work/drivers/spi/spi_bitbang.c 2009-11-25 15:30:45.000000000 +0900 @@ -176,6 +176,14 @@ int spi_bitbang_setup_transfer(struct sp } EXPORT_SYMBOL_GPL(spi_bitbang_setup_transfer); +static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t) +{ + struct spi_bitbang_cs *cs = spi->controller_state; + unsigned nsecs = cs->nsecs; + + return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t); +} + /** * spi_bitbang_setup - default setup for per-word I/O loops */ @@ -183,6 +191,7 @@ int spi_bitbang_setup(struct spi_device { struct spi_bitbang_cs *cs = spi->controller_state; struct spi_bitbang *bitbang; + int mode_mask = SPI_CPOL | SPI_CPHA; int retval; unsigned long flags; @@ -196,9 +205,11 @@ int spi_bitbang_setup(struct spi_device } /* per-word shift register access, in hardware or bitbanging */ - cs->txrx_word = bitbang->txrx_word[spi->mode & (SPI_CPOL|SPI_CPHA)]; - if (!cs->txrx_word) - return -EINVAL; + if (bitbang->txrx_bufs == spi_bitbang_bufs) { + cs->txrx_word = bitbang->txrx_word[spi->mode & mode_mask]; + if (!cs->txrx_word) + return -EINVAL; + } retval = bitbang->setup_transfer(spi, NULL); if (retval < 0) @@ -232,14 +243,6 @@ void spi_bitbang_cleanup(struct spi_devi } EXPORT_SYMBOL_GPL(spi_bitbang_cleanup); -static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t) -{ - struct spi_bitbang_cs *cs = spi->controller_state; - unsigned nsecs = cs->nsecs; - - return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t); -} - /*----------------------------------------------------------------------*/ /* --- 0002/drivers/spi/spi_sh_msiof.c +++ work/drivers/spi/spi_sh_msiof.c 2009-11-25 15:25:32.000000000 +0900 @@ -510,13 +510,6 @@ static int sh_msiof_spi_txrx(struct spi_ return bytes_done; } -static u32 sh_msiof_spi_txrx_word(struct spi_device *spi, unsigned nsecs, - u32 word, u8 bits) -{ - BUG_ON(1); /* unused but needed by bitbang code */ - return 0; -} - static int sh_msiof_spi_probe(struct platform_device *pdev) { struct resource *r; @@ -594,10 +587,6 @@ static int sh_msiof_spi_probe(struct pla p->bitbang.chipselect = sh_msiof_spi_chipselect; p->bitbang.setup_transfer = sh_msiof_spi_setup_transfer; p->bitbang.txrx_bufs = sh_msiof_spi_txrx; - p->bitbang.txrx_word[SPI_MODE_0] = sh_msiof_spi_txrx_word; - p->bitbang.txrx_word[SPI_MODE_1] = sh_msiof_spi_txrx_word; - p->bitbang.txrx_word[SPI_MODE_2] = sh_msiof_spi_txrx_word; - p->bitbang.txrx_word[SPI_MODE_3] = sh_msiof_spi_txrx_word; ret = spi_bitbang_start(&p->bitbang); if (ret == 0)