From: Vinod Koul Date: Mon, 16 Dec 2013 03:50:42 +0000 (+0530) Subject: Merge branch 'topic/of' into next X-Git-Tag: next-20131220~63^2~1 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=ec878fec2854510ac224db4ed7604638bcc4d37d;p=karo-tx-linux.git Merge branch 'topic/of' into next Conflicts: drivers/dma/mmp_pdma.c Signed-off-by: Vinod Koul --- ec878fec2854510ac224db4ed7604638bcc4d37d 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; }