1. In order to remove duplicate code, following functions: platform_get_resource devm_kzalloc devm_ioremap_resource devm_clk_get platform_get_irq clk_prepare_enable are replaced with a macro devm_platform_probe_helper. 2. This patch depends on the file include/linux/probe-helper.h which is pushed in previous patch [01/09]. Signed-off-by: Satendra Singh Thakur <satendrasingh.thakur@xxxxxxx> Signed-off-by: Satendra Singh Thakur <sst2005@xxxxxxxxx> --- drivers/dma/dma-axi-dmac.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c index a0ee404b736e..ac8a2355b299 100644 --- a/drivers/dma/dma-axi-dmac.c +++ b/drivers/dma/dma-axi-dmac.c @@ -21,6 +21,7 @@ #include <linux/regmap.h> #include <linux/slab.h> #include <linux/fpga/adi-axi-common.h> +#include <linux/probe-helper.h> #include <dt-bindings/dma/axi-dmac.h> @@ -829,28 +830,19 @@ 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; int ret; - dmac = devm_kzalloc(&pdev->dev, sizeof(*dmac), GFP_KERNEL); - if (!dmac) - return -ENOMEM; - - dmac->irq = platform_get_irq(pdev, 0); - if (dmac->irq < 0) - return dmac->irq; - if (dmac->irq == 0) + /* + * This macro internally combines following functions: + * devm_kzalloc, platform_get_resource, devm_ioremap_resource, + * devm_clk_get, platform_get_irq + */ + ret = devm_platform_probe_helper(pdev, dmac, NULL); + if (ret < 0) + return ret; + else if (!dmac->irq) return -EINVAL; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - dmac->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(dmac->base)) - return PTR_ERR(dmac->base); - - dmac->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(dmac->clk)) - return PTR_ERR(dmac->clk); - INIT_LIST_HEAD(&dmac->chan.active_descs); of_channels = of_get_child_by_name(pdev->dev.of_node, "adi,channels"); -- 2.17.1