From patchwork Mon Aug 19 05:25:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 2846354 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 ADA8A9F239 for ; Mon, 19 Aug 2013 06:09:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FCE2202AB for ; Mon, 19 Aug 2013 06:09:04 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05B5F2029B for ; Mon, 19 Aug 2013 06:09:03 +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 1VBIeC-0003ja-9y; Mon, 19 Aug 2013 06:09:00 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBIeA-0004he-2k; Mon, 19 Aug 2013 06:08:58 +0000 Received: from mga03.intel.com ([143.182.124.21]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VBIe6-0004h2-H6 for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2013 06:08:56 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga101.ch.intel.com with ESMTP; 18 Aug 2013 23:08:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,910,1367996400"; d="scan'208";a="283698598" Received: from vkoul-udesk3.iind.intel.com ([10.223.84.41]) by AZSMGA002.ch.intel.com with ESMTP; 18 Aug 2013 23:08:30 -0700 Received: from vkoul-udesk3.iind.intel.com (localhost [127.0.0.1]) by vkoul-udesk3.iind.intel.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id r7J5PIpS019045; Mon, 19 Aug 2013 10:55:18 +0530 Received: (from vkoul@localhost) by vkoul-udesk3.iind.intel.com (8.14.3/8.14.3/Submit) id r7J5PG2P019043; Mon, 19 Aug 2013 10:55:16 +0530 X-Authentication-Warning: vkoul-udesk3.iind.intel.com: vkoul set sender to vinod.koul@intel.com using -f Date: Mon, 19 Aug 2013 10:55:16 +0530 From: Vinod Koul To: Zhangfei Gao Subject: Re: [PATCH v3 1/2] dmaengine: add interface of dma_get_slave_channel Message-ID: <20130819052516.GT32147@intel.com> References: <1376550163-30145-1-git-send-email-zhangfei.gao@linaro.org> <1376550163-30145-2-git-send-email-zhangfei.gao@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1376550163-30145-2-git-send-email-zhangfei.gao@linaro.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130819_020855_114795_98FBA006 X-CRM114-Status: GOOD ( 23.96 ) X-Spam-Score: -9.7 (---------) Cc: linux-arm-kernel@lists.infradead.org, Dan Carpenter , Arnd Bergmann 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 On Thu, Aug 15, 2013 at 03:02:42PM +0800, Zhangfei Gao wrote: > Suggested by Arnd, add dma_get_slave_channel interface > Dma host driver could get specific channel specificied by request line, rather than filter. > > host example: > static struct dma_chan *xx_of_dma_simple_xlate(struct of_phandle_args *dma_spec, > struct of_dma *ofdma) > { > struct xx_dma_dev *d = ofdma->of_dma_data; > unsigned int request = dma_spec->args[0]; > > if (request > d->dma_requests) > return NULL; > > return dma_get_slave_channel(&(d->chans[request].vc.chan)); > } > > probe: > of_dma_controller_register((&op->dev)->of_node, xx_of_dma_simple_xlate, d); > > Signed-off-by: Zhangfei Gao > Acked-by: Arnd Bergmann > --- > drivers/dma/dmaengine.c | 25 +++++++++++++++++++++++++ > include/linux/dmaengine.h | 1 + > 2 files changed, 26 insertions(+) > > diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c > index 9e56745..38dd8c3 100644 > --- a/drivers/dma/dmaengine.c > +++ b/drivers/dma/dmaengine.c > @@ -504,6 +504,31 @@ static struct dma_chan *private_candidate(const dma_cap_mask_t *mask, > } > > /** > + * dma_request_channel - try to get specific channel exclusively > + * @chan: target channel > + */ > +struct dma_chan *dma_get_slave_channel(struct dma_chan *chan) > +{ > + int err = -EBUSY; > + > + /* lock against __dma_request_channel */ > + mutex_lock(&dma_list_mutex); > + > + if (chan->client_count == 0) { > + err = dma_chan_get(chan); > + if (err) > + pr_debug("%s: failed to get %s: (%d)\n", > + __func__, dma_chan_name(chan), err); > + } else > + chan = NULL; > + > + mutex_unlock(&dma_list_mutex); > + > + return chan; > +} > +EXPORT_SYMBOL_GPL(dma_get_slave_channel); No, this is not the right approach. When patch is applied and you find an issue you fix the issue. I have already pushed and merged this. So removing is a bad idea. you provide a fix for this miss. Also for this you need to give due credit to Dan (reporter). That is how the process works. Anyway I have applied the below fix and will push it out. --- dmaengine: fix - error: potential NULL dereference 'chan' commit 7bb587f4 "dmaengine: add interface of dma_get_slave_channel" introduced the above error so fix it Reported-by: Dan Carpenter Suggested-by: Zhangfei Gao Signed-off-by: Vinod Koul --- drivers/dma/dmaengine.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) -- ~Vinod diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 5932ab1..755ba2f 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -514,16 +514,16 @@ struct dma_chan *dma_get_slave_channel(struct dma_chan *chan) /* lock against __dma_request_channel */ mutex_lock(&dma_list_mutex); - if (chan->client_count == 0) + if (chan->client_count == 0) { err = dma_chan_get(chan); - else + if (err) + pr_debug("%s: failed to get %s: (%d)\n", + __func__, dma_chan_name(chan), err); + } else chan = NULL; mutex_unlock(&dma_list_mutex); - if (err) - pr_debug("%s: failed to get %s: (%d)\n", - __func__, dma_chan_name(chan), err); return chan; }