From patchwork Sat Sep 27 08:54:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 4989631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DB8CD9F2BB for ; Sat, 27 Sep 2014 08:59:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0FA2C20204 for ; Sat, 27 Sep 2014 08:59:53 +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 3C803201E4 for ; Sat, 27 Sep 2014 08:59:52 +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 1XXnoy-0000oZ-OC; Sat, 27 Sep 2014 08:57:40 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XXnoR-00005T-Bo for linux-arm-kernel@lists.infradead.org; Sat, 27 Sep 2014 08:57:07 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 1A3F019FB; Sat, 27 Sep 2014 10:56:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (unknown [80.12.35.177]) by mail.free-electrons.com (Postfix) with ESMTPSA id 66D5E6FD; Sat, 27 Sep 2014 10:56:46 +0200 (CEST) From: Maxime Ripard To: Vinod Koul , dmaengine@vger.kernel.org Subject: [PATCH 6/9] dmaengine: Create a generic dma_slave_caps callback Date: Sat, 27 Sep 2014 10:54:42 +0200 Message-Id: <1411808085-27792-7-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1411808085-27792-1-git-send-email-maxime.ripard@free-electrons.com> References: <1411808085-27792-1-git-send-email-maxime.ripard@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140927_015707_561823_A09E4E01 X-CRM114-Status: GOOD ( 12.01 ) X-Spam-Score: 0.3 (/) Cc: lars@metafoo.de, linux-kernel@vger.kernel.org, Laurent Pinchart , Maxime Ripard , linux-arm-kernel@lists.infradead.org, =?UTF-8?q?Antoine=20T=C3=A9nart?= 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-Virus-Scanned: ClamAV using ClamSMTP dma_slave_caps is very important to the generic layers that might interact with dmaengine, such as ASoC. Unfortunately, it has been added as yet another dma_device callback, and most of the existing drivers haven't implemented it, reducing its reliability. Introduce a generic behaviour, pre-filling the dma_slave_caps struct with what it knows about the dma controller, before calling the dma_device callback, both to maintain a backward compatibility and to make sure that drivers can override that generic behaviour. Signed-off-by: Maxime Ripard --- include/linux/dmaengine.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 4d0294ec3567..cfcbee145898 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -772,17 +772,24 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_interleaved_dma( static inline int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps) { + struct dma_device *device; + if (!chan || !caps) return -EINVAL; + device = chan->device; + /* check if the channel supports slave transactions */ - if (!test_bit(DMA_SLAVE, chan->device->cap_mask.bits)) + if (!test_bit(DMA_SLAVE, device->cap_mask.bits)) return -ENXIO; - if (chan->device->device_slave_caps) - return chan->device->device_slave_caps(chan, caps); + caps->cmd_pause = !!device->device_pause; + caps->cmd_terminate = !!device->device_terminate_all; + + if (device->device_slave_caps) + return device->device_slave_caps(chan, caps); - return -ENXIO; + return 0; } static inline int dmaengine_terminate_all(struct dma_chan *chan)