From patchwork Mon Nov 17 22:47:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beniamino Galvani X-Patchwork-Id: 5324271 Return-Path: X-Original-To: patchwork-linux-arm@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 B6C24C11AC for ; Mon, 17 Nov 2014 22:52:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E445F2011D for ; Mon, 17 Nov 2014 22:52:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 269A920127 for ; Mon, 17 Nov 2014 22:52:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XqV8I-0006On-Ax; Mon, 17 Nov 2014 22:50:54 +0000 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XqV8C-0005qm-7j for linux-arm-kernel@lists.infradead.org; Mon, 17 Nov 2014 22:50:49 +0000 Received: by mail-wi0-f181.google.com with SMTP id r20so4383696wiv.2 for ; Mon, 17 Nov 2014 14:50:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vvZWkfQ7NwrWzqll6jzDV+uqDNBm1HSR74j5U4aeqGc=; b=prZ7kjEg+HYtSsljLUL5x0HGzpSMHr8IDasxEHaW5K76LZVC2DN4/szRLT3FAhOQdC zX74ipHF6wbhR1Yb/EiRiruFfLyZWW/fiLCKZj/xuKxEe5W3gkVn2yXZSrg2CX+BjwBH uQPBmI9DWJ1/o2e0FPSg2fRgWSuFn67MG4Mo971kOGyArLMImhZYPc1FMUnCGinfNUAc Iwzv3wCHRLZdphx1PLBGXeAboAeUMskRtgNDCja+oRdDPLpyTJfJShxeqHo3RdqK1mTN w6n/pZrn7/AVmYXiq6RPz8BvxzVu/LiU/fwBTtXQXeVqofv/006/rVt3o+UVijmvkOnB +p+A== X-Received: by 10.194.93.168 with SMTP id cv8mr14897151wjb.114.1416264628209; Mon, 17 Nov 2014 14:50:28 -0800 (PST) Received: from sark.local (host115-93-dynamic.40-79-r.retail.telecomitalia.it. [79.40.93.115]) by mx.google.com with ESMTPSA id cu9sm53383417wjb.0.2014.11.17.14.50.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Nov 2014 14:50:27 -0800 (PST) From: Beniamino Galvani To: Mark Brown Subject: [PATCH v2 1/4] spi: Add 'last' flag to spi_transfer structure Date: Mon, 17 Nov 2014 23:47:48 +0100 Message-Id: <1416264471-774-2-git-send-email-b.galvani@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416264471-774-1-git-send-email-b.galvani@gmail.com> References: <1416264471-774-1-git-send-email-b.galvani@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141117_145048_515327_7EBC5100 X-CRM114-Status: GOOD ( 13.53 ) X-Spam-Score: -0.8 (/) Cc: Mark Rutland , devicetree@vger.kernel.org, Russell King , Victor Wan , Pawel Moll , Ian Campbell , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Beniamino Galvani , Rob Herring , Kumar Gala , Carlo Caione , Jerry Cao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Some drivers need to know whether the current transfer is the last in the message in order to properly handle CS. A common way to achieve this is to reimplement transfer_one_message() but this leads to undesirable code duplication. This patch adds a 'last' field to the spi_transfer structure and populates it before passing the structure to the driver. Signed-off-by: Beniamino Galvani --- drivers/spi/spi.c | 6 ++++++ include/linux/spi/spi.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index ebcb33d..fc7f02d 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -887,6 +887,7 @@ static void spi_pump_messages(struct kthread_work *work) { struct spi_master *master = container_of(work, struct spi_master, pump_messages); + struct spi_transfer *xfer; unsigned long flags; bool was_busy = false; int ret; @@ -941,6 +942,11 @@ static void spi_pump_messages(struct kthread_work *work) } } + list_for_each_entry(xfer, &master->cur_msg->transfers, transfer_list) { + xfer->last = list_is_last(&xfer->transfer_list, + &master->cur_msg->transfers); + } + if (!was_busy) trace_spi_master_busy(master); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 46d188a..37f055a 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -535,6 +535,7 @@ extern struct spi_master *spi_busnum_to_master(u16 busnum); * (SPI_NBITS_SINGLE) is used. * @rx_nbits: number of bits used for reading. If 0 the default * (SPI_NBITS_SINGLE) is used. + * @last: whether the transfer is the last in the message. * @len: size of rx and tx buffers (in bytes) * @speed_hz: Select a speed other than the device default for this * transfer. If 0 the default (from @spi_device) is used. @@ -620,6 +621,7 @@ struct spi_transfer { unsigned cs_change:1; unsigned tx_nbits:3; unsigned rx_nbits:3; + unsigned last:1; #define SPI_NBITS_SINGLE 0x01 /* 1bit transfer */ #define SPI_NBITS_DUAL 0x02 /* 2bits transfer */ #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */