From: Vinod Koul Date: Tue, 7 Jan 2014 16:06:24 +0000 (+0530) Subject: Merge branch 'topic/of' into for-linus X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0adcdeed6f87ac7230c9a0364ac785b8e70ad275;p=linux-beck.git Merge branch 'topic/of' into for-linus Conflicts: drivers/dma/mmp_pdma.c Signed-off-by: Vinod Koul --- 0adcdeed6f87ac7230c9a0364ac785b8e70ad275 diff --cc drivers/dma/mmp_pdma.c index 3f7712c4d3fa,2998f1bffac1..c1b7c3ac7676 --- a/drivers/dma/mmp_pdma.c +++ b/drivers/dma/mmp_pdma.c @@@ -898,30 -893,15 +898,21 @@@ static struct dma_chan *mmp_pdma_dma_xl struct of_dma *ofdma) { struct mmp_pdma_device *d = ofdma->of_dma_data; - struct dma_chan *chan, *candidate; + struct dma_chan *chan; + struct mmp_pdma_chan *c; - 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) + chan = dma_get_any_slave_channel(&d->device); + if (!chan) return NULL; - c = to_mmp_pdma_chan(chan); - c->drcmr = dma_spec->args[0]; + /* dma_get_slave_channel will return NULL if we lost a race between + * the lookup and the reservation */ + chan = dma_get_slave_channel(candidate); + + if (!chan) + goto retry; + + to_mmp_pdma_chan(chan)->drcmr = dma_spec->args[0]; return chan; }