Skip to content

Commit

Permalink
dmaengine: axi-dmac: wrap entire dt parse in a function
Browse files Browse the repository at this point in the history
All these attributes will be read from registers in newer core versions, so
just wrap the logic into a function.

Signed-off-by: Alexandru Ardelean <[email protected]>
  • Loading branch information
commodo committed Aug 19, 2020
1 parent 8dfa1bb commit 9b0131f
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions drivers/dma/dma-axi-dmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,28 @@ static int axi_dmac_parse_chan_dt(struct device_node *of_chan,
return 0;
}

static int axi_dmac_parse_dt(struct device *dev, struct axi_dmac *dmac)
{
struct device_node *of_channels, *of_chan;
int ret;

of_channels = of_get_child_by_name(dev->of_node, "adi,channels");
if (of_channels == NULL)
return -ENODEV;

for_each_child_of_node(of_channels, of_chan) {
ret = axi_dmac_parse_chan_dt(of_chan, &dmac->chan);
if (ret) {
of_node_put(of_chan);
of_node_put(of_channels);
return -EINVAL;
}
}
of_node_put(of_channels);

return 0;
}

static int axi_dmac_detect_caps(struct axi_dmac *dmac, unsigned int version)
{
struct axi_dmac_chan *chan = &dmac->chan;
Expand Down Expand Up @@ -887,7 +909,6 @@ static int axi_dmac_detect_caps(struct axi_dmac *dmac, unsigned int version)

static int axi_dmac_probe(struct platform_device *pdev)
{
struct device_node *of_channels, *of_chan;
struct dma_device *dma_dev;
struct axi_dmac *dmac;
struct resource *res;
Expand Down Expand Up @@ -919,19 +940,9 @@ static int axi_dmac_probe(struct platform_device *pdev)

INIT_LIST_HEAD(&dmac->chan.active_descs);

of_channels = of_get_child_by_name(pdev->dev.of_node, "adi,channels");
if (of_channels == NULL)
return -ENODEV;

for_each_child_of_node(of_channels, of_chan) {
ret = axi_dmac_parse_chan_dt(of_chan, &dmac->chan);
if (ret) {
of_node_put(of_chan);
of_node_put(of_channels);
return -EINVAL;
}
}
of_node_put(of_channels);
ret = axi_dmac_parse_dt(&pdev->dev, dmac);
if (ret < 0)
return ret;

pdev->dev.dma_parms = &dmac->dma_parms;
dma_set_max_seg_size(&pdev->dev, UINT_MAX);
Expand Down

0 comments on commit 9b0131f

Please sign in to comment.