From patchwork Fri May 31 15:01:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 2644461 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 9E24BDFB79 for ; Fri, 31 May 2013 15:04:21 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UiQrU-0001Qv-Dm; Fri, 31 May 2013 15:03:26 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UiQqj-00043A-8H; Fri, 31 May 2013 15:02:37 +0000 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UiQqg-00042O-5n for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2013 15:02:34 +0000 Received: by mail-wi0-f171.google.com with SMTP id hq7so786029wib.4 for ; Fri, 31 May 2013 08:02:12 -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:x-mailer; bh=yAN4xuASILB5wVyv7WFW+lPEjyY8ipAtBlImg+Axgtg=; b=sWQ1hMoghGmfzN2IvLga87guiQ4qZnGnLGbSeJ5Gm7TqxcveNku2VxSH3QNYDbuEv+ o40Z7+AJDHUpIqcWBtxsqAVGmPv3Q9qttbbsRCIycfOQAXmKpSZfkFqNqQLWTBaXiJ1R iY8pSU1a3UayBpR5YJ4f5rRFeLEIFy3jpQMw3R+pJBxLGd/0GbGX4NC7glWdtiVN0I1m XHsEFPQwL1enAG7qFdJFEsQT9sXnQH56xJbMD5OTyL7LjIUP3gq5/oUDu1cX7NRmlvCE zDAK1ZNZB069xrDGrJ+QBRjZ04OJnr3En3F2G4qjPPLhVWR/SQ/69M8EfPwytarPHtNO 8uQw== X-Received: by 10.194.123.9 with SMTP id lw9mr9880452wjb.24.1370012532636; Fri, 31 May 2013 08:02:12 -0700 (PDT) Received: from lnx-rg.pr (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPSA id ay7sm4497188wib.9.2013.05.31.08.02.10 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 May 2013 08:02:11 -0700 (PDT) From: Richard Genoud To: Nicolas Ferre Subject: [PATCH 1/2] spi: atmel: convert to dma_request_slave_channel_compat() Date: Fri, 31 May 2013 17:01:59 +0200 Message-Id: <1370012520-30539-1-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130531_110234_369814_C4EC068D X-CRM114-Status: GOOD ( 12.25 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (richard.genoud[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -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: Ludovic Desroches , Richard Genoud , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Mark Brown , Grant Likely , Jean-Christophe PLAGNIOL-VILLARD , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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 Use generic DMA DT helper. Platforms booting with or without DT populated are both supported. Based on Ludovic Desroches patchset "ARM: at91: move to generic DMA device tree binding" Signed-off-by: Richard Genoud Acked-by: Ludovic Desroches Tested-by: Wenyou Yang --- drivers/spi/spi-atmel.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) rebased on linux-next next-20130531 diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 31cfc87..ea1ec00 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -424,10 +424,15 @@ static int atmel_spi_dma_slave_config(struct atmel_spi *as, return err; } -static bool filter(struct dma_chan *chan, void *slave) +static bool filter(struct dma_chan *chan, void *pdata) { - struct at_dma_slave *sl = slave; + struct atmel_spi_dma *sl_pdata = pdata; + struct at_dma_slave *sl; + if (!sl_pdata) + return false; + + sl = &sl_pdata->dma_slave; if (sl->dma_dev == chan->device->dev) { chan->private = sl; return true; @@ -438,24 +443,31 @@ static bool filter(struct dma_chan *chan, void *slave) static int atmel_spi_configure_dma(struct atmel_spi *as) { - struct at_dma_slave *sdata = &as->dma.dma_slave; struct dma_slave_config slave_config; + struct device *dev = &as->pdev->dev; int err; - if (sdata && sdata->dma_dev) { - dma_cap_mask_t mask; + dma_cap_mask_t mask; + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); - /* Try to grab two DMA channels */ - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); - as->dma.chan_tx = dma_request_channel(mask, filter, sdata); - if (as->dma.chan_tx) - as->dma.chan_rx = - dma_request_channel(mask, filter, sdata); + as->dma.chan_tx = dma_request_slave_channel_compat(mask, filter, + &as->dma, + dev, "tx"); + if (!as->dma.chan_tx) { + dev_err(dev, + "DMA TX channel not available, SPI unable to use DMA\n"); + err = -EBUSY; + goto error; } - if (!as->dma.chan_rx || !as->dma.chan_tx) { - dev_err(&as->pdev->dev, - "DMA channel not available, SPI unable to use DMA\n"); + + as->dma.chan_rx = dma_request_slave_channel_compat(mask, filter, + &as->dma, + dev, "rx"); + + if (!as->dma.chan_rx) { + dev_err(dev, + "DMA RX channel not available, SPI unable to use DMA\n"); err = -EBUSY; goto error; }