From patchwork Thu Aug 29 01:01:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L5a6H6Iiq?= X-Patchwork-Id: 270662 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 827222C00C3 for ; Thu, 29 Aug 2013 11:09:15 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VEqjD-0001TY-CR; Thu, 29 Aug 2013 01:08:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VEqjA-0005U6-Jw; Thu, 29 Aug 2013 01:08:48 +0000 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VEqj8-0005Tm-4N for linux-mtd@lists.infradead.org; Thu, 29 Aug 2013 01:08:47 +0000 Received: by mail-pa0-f54.google.com with SMTP id kx10so192151pab.13 for ; Wed, 28 Aug 2013 18:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Dd43JsepwJotJufbp3R5Htob4ddDWDKBQ2YHqdresb8=; b=wVdOxO/Apx875pxI+X4pTK2U+4z7k6NVKUnVrj8k5XCkpPkwYdZQBgY+et2z4udvGw jk3lCJ7H4VccnTZzRu0R7yDd9ZqvgcwbVPN/AfQ/aSKDnpxPd3y6zIWcILqv1PUQa7i1 O6Ycpw7cDLqjNRnlhkOGLehnvdFwXntHRdiZPzb787rmx21kU+MZBKSHDxsil56Ea/+9 6Ei2RpSWZUW1HEVWQUcrJ8urFglw3YRcGsqz9IgUibnqB2fUFIciw8Jw8Er5wdn1HJBr 5PZMGh9Gu9ShvvZ87R2UoUu9Mgb+AzfYe/eHUL5bmTSd+uU2sO7P+T7I1COzZzUpUo/+ otbg== X-Received: by 10.66.120.145 with SMTP id lc17mr192596pab.182.1377738182048; Wed, 28 Aug 2013 18:03:02 -0700 (PDT) Received: from localhost.localdomain ([218.24.172.134]) by mx.google.com with ESMTPSA id ye1sm20581799pab.19.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Aug 2013 18:03:01 -0700 (PDT) From: wangyuhang To: broonie@kernel.org, linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org, pekon@ti.com Subject: [PATCH V2] spi: dual and quad support(add single macro) Date: Thu, 29 Aug 2013 09:01:50 +0800 Message-Id: <1377738110-4219-1-git-send-email-wangyuhang2014@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130828_210846_324009_6B027981 X-CRM114-Status: GOOD ( 11.26 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (wangyuhang2014[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (wangyuhang2014[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: wangyuhang X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org fix two things in patch: commit id:f477b7fb13df2b843997559ff34e87d054ba6538 1.Add SPI_TX_SINGLE and SPI_RX_SINGLE to specify SINGLE mode. Instead of using default value in mode. 2.Delete a "return" when commit the patch to a new kernel version by mistake. So recover it. Signed-off-by: wangyuhang --- drivers/spi/spi.c | 5 +++++ include/linux/spi/spi.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 8d191f2..81bdc96 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -873,9 +873,11 @@ static void of_register_spi_devices(struct spi_master *master) prop = of_get_property(nc, "spi-tmax-nbits", &len); if (!prop || len < sizeof(*prop)) { /* set tx mode in SINGLE as default */ + spi->mode &= SPI_TX_SINGLE; } else { switch (be32_to_cpup(prop)) { case SPI_NBITS_SINGLE: + spi->mode &= SPI_TX_SINGLE; break; case SPI_NBITS_DUAL: spi->mode |= SPI_TX_DUAL; @@ -893,9 +895,11 @@ static void of_register_spi_devices(struct spi_master *master) prop = of_get_property(nc, "spi-rmax-nbits", &len); if (!prop || len < sizeof(*prop)) { /* set rx mode in SINGLE as default */ + spi->mode &= SPI_RX_SINGLE; } else { switch (be32_to_cpup(prop)) { case SPI_NBITS_SINGLE: + spi->mode &= SPI_RX_SINGLE; break; case SPI_NBITS_DUAL: spi->mode |= SPI_RX_DUAL; @@ -1459,6 +1463,7 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) return -EINVAL; if (xfer->speed_hz && master->max_speed_hz && xfer->speed_hz > master->max_speed_hz) + return -EINVAL; if (xfer->tx_buf && !xfer->tx_nbits) xfer->tx_nbits = SPI_NBITS_SINGLE; diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index ccd7840..faa138c 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -89,8 +89,12 @@ struct spi_device { #define SPI_READY 0x80 /* slave pulls low to pause */ #define SPI_TX_DUAL 0x100 /* transmit with 2 wires */ #define SPI_TX_QUAD 0x200 /* transmit with 4 wires */ +/* transmit with 1 wire(not using dual-tx and quad-tx) */ +#define SPI_TX_SINGLE ~(SPI_TX_DUAL | SPI_TX_QUAD) #define SPI_RX_DUAL 0x400 /* receive with 2 wires */ #define SPI_RX_QUAD 0x800 /* receive with 4 wires */ +/* receive with 1 wire(not using dual-rx and quad-rx) */ +#define SPI_RX_SINGLE ~(SPI_RX_DUAL | SPI_RX_QUAD) u8 bits_per_word; int irq; void *controller_state;