From patchwork Mon Nov 25 21:48:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 3234761 Return-Path: X-Original-To: patchwork-dmaengine@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 3529E9F3A0 for ; Mon, 25 Nov 2013 21:49:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6148F2024F for ; Mon, 25 Nov 2013 21:48:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 24A36201B4 for ; Mon, 25 Nov 2013 21:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751810Ab3KYVs5 (ORCPT ); Mon, 25 Nov 2013 16:48:57 -0500 Received: from avon.wwwdotorg.org ([70.85.31.133]:57959 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751102Ab3KYVs5 (ORCPT ); Mon, 25 Nov 2013 16:48:57 -0500 Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 4D0FF6232; Mon, 25 Nov 2013 14:48:57 -0700 (MST) Received: from swarren-lx1.nvidia.com (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id E6233E4623; Mon, 25 Nov 2013 14:48:53 -0700 (MST) From: Stephen Warren To: Dan Williams , Vinod Koul Cc: Stephen Warren , dmaengine@vger.kernel.org Subject: [PATCH] dma: mmp_pdma: use of_dma_slave_xlate() Date: Mon, 25 Nov 2013 14:48:51 -0700 Message-Id: <1385416131-3293-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.8.1.5 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.97.8 at avon.wwwdotorg.org X-Virus-Status: Clean Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Stephen Warren Use the new common of_dma_slave_xlate() function to avoid duplicating most of the of_xlate() implementation. Cc: Dan Williams Cc: Vinod Koul Cc: dmaengine@vger.kernel.org Signed-off-by: Stephen Warren --- This patch depends on the previous "dma: add common of_dma_slave_xlate()", but isn't a dependency for other branches, so can be applied just to the regular drivers/dma tree once the dependency is merged in. --- drivers/dma/mmp_pdma.c | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c index dcb1e05149a7..9705cedf623d 100644 --- a/drivers/dma/mmp_pdma.c +++ b/drivers/dma/mmp_pdma.c @@ -128,6 +128,7 @@ struct mmp_pdma_device { void __iomem *base; struct device *dev; struct dma_device device; + struct of_dma_slave_xlate_info xlate_info; struct mmp_pdma_phy *phy; spinlock_t phy_lock; /* protect alloc/free phy channels */ }; @@ -889,37 +890,14 @@ static struct of_device_id mmp_pdma_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, mmp_pdma_dt_ids); -static struct dma_chan *mmp_pdma_dma_xlate(struct of_phandle_args *dma_spec, - struct of_dma *ofdma) +static int mmp_pdma_of_xlate_post_alloc(struct dma_chan *chan, + struct of_phandle_args *dma_spec) { - struct mmp_pdma_device *d = ofdma->of_dma_data; - struct dma_chan *chan, *candidate; - -retry: - candidate = NULL; - - /* walk the list of channels registered with the current instance and - * find one that is currently unused */ - list_for_each_entry(chan, &d->device.channels, device_node) - if (chan->client_count == 0) { - candidate = chan; - break; - } - - if (!candidate) - return NULL; + struct mmp_pdma_chan *c = to_mmp_pdma_chan(chan); - /* dma_get_slave_channel will return NULL if we lost a race between - * the lookup and the reservation */ - chan = dma_get_slave_channel(candidate); + c->drcmr = dma_spec->args[0]; - if (chan) { - struct mmp_pdma_chan *c = to_mmp_pdma_chan(chan); - c->drcmr = dma_spec->args[0]; - return chan; - } - - goto retry; + return 0; } static int mmp_pdma_probe(struct platform_device *op) @@ -1009,8 +987,11 @@ static int mmp_pdma_probe(struct platform_device *op) if (op->dev.of_node) { /* Device-tree DMA controller registration */ + pdev->xlate_info.device = &pdev->device; + pdev->xlate_info.post_alloc = mmp_pdma_of_xlate_post_alloc; ret = of_dma_controller_register(op->dev.of_node, - mmp_pdma_dma_xlate, pdev); + of_dma_slave_xlate, + &pdev->xlate_info); if (ret < 0) { dev_err(&op->dev, "of_dma_controller_register failed\n"); return ret;