diff options
author | Alexandru Ardelean <alexandru.ardelean@analog.com> | 2020-08-25 18:19:48 +0300 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2020-08-25 18:37:10 +0300 |
commit | 06b6e88c7ecf48e666bdd88615fa46155c8cb8f1 (patch) | |
tree | 6194f33673237494cd3db1198b64c45ad606622a /drivers/dma/dma-axi-dmac.c | |
parent | 08b36dba23e5b26a3f5dbeb5b0d8d7462ab38c12 (diff) | |
download | linux-06b6e88c7ecf48e666bdd88615fa46155c8cb8f1.tar.xz |
dmaengine: axi-dmac: wrap entire dt parse in a function
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 <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200825151950.57605-5-alexandru.ardelean@analog.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma/dma-axi-dmac.c')
-rw-r--r-- | drivers/dma/dma-axi-dmac.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c index f4b17b5e3914..1a1e227fa935 100644 --- a/drivers/dma/dma-axi-dmac.c +++ b/drivers/dma/dma-axi-dmac.c @@ -774,6 +774,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; @@ -823,7 +845,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; @@ -854,22 +875,9 @@ static int axi_dmac_probe(struct platform_device *pdev) if (ret < 0) return ret; - of_channels = of_get_child_by_name(pdev->dev.of_node, "adi,channels"); - if (of_channels == NULL) { - ret = -ENODEV; + ret = axi_dmac_parse_dt(&pdev->dev, dmac); + if (ret < 0) goto err_clk_disable; - } - - 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); - ret = -EINVAL; - goto err_clk_disable; - } - } - of_node_put(of_channels); INIT_LIST_HEAD(&dmac->chan.active_descs); |