linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Satendra Singh Thakur <sst2005@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: satendrasingh.thakur@hcl.com,
	Satendra Singh Thakur <sst2005@gmail.com>,
	Jun Nie <jun.nie@linaro.org>, Shawn Guo <shawnguo@kernel.org>,
	Vinod Koul <vkoul@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>,
	linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 3/9] probe/dma/zx: removed redundant code from zx dma controller's probe function
Date: Sun, 15 Sep 2019 12:59:38 +0530	[thread overview]
Message-ID: <20190915072938.23610-1-sst2005@gmail.com> (raw)
In-Reply-To: <20190915072644.23329-1-sst2005@gmail.com>

1. In order to remove duplicate code, following functions:
platform_get_resource
devm_kzalloc
devm_ioremap_resource
devm_clk_get
platform_get_irq
devm_request_irq
are replaced with a macro devm_platform_probe_helper_irq.

2. Removed dmam_pool_destroy from remove method as dmam_pool_create
is already used in probe function.

3. 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@hcl.com>
Signed-off-by: Satendra Singh Thakur <sst2005@gmail.com>
---
 drivers/dma/zx_dma.c | 35 ++++++++++-------------------------
 1 file changed, 10 insertions(+), 25 deletions(-)

diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c
index 9f4436f7c914..d8c2fbe9766c 100644
--- a/drivers/dma/zx_dma.c
+++ b/drivers/dma/zx_dma.c
@@ -18,6 +18,7 @@
 #include <linux/of.h>
 #include <linux/clk.h>
 #include <linux/of_dma.h>
+#include <linux/probe-helper.h>
 
 #include "virt-dma.h"
 
@@ -754,20 +755,17 @@ static struct dma_chan *zx_of_dma_simple_xlate(struct of_phandle_args *dma_spec,
 static int zx_dma_probe(struct platform_device *op)
 {
 	struct zx_dma_dev *d;
-	struct resource *iores;
 	int i, ret = 0;
 
-	iores = platform_get_resource(op, IORESOURCE_MEM, 0);
-	if (!iores)
-		return -EINVAL;
-
-	d = devm_kzalloc(&op->dev, sizeof(*d), GFP_KERNEL);
-	if (!d)
-		return -ENOMEM;
-
-	d->base = devm_ioremap_resource(&op->dev, iores);
-	if (IS_ERR(d->base))
-		return PTR_ERR(d->base);
+	/*
+	 * This macro internally combines following functions:
+	 * devm_kzalloc, platform_get_resource, devm_ioremap_resource,
+	 * devm_clk_get, platform_get_irq, devm_request_irq,
+	 */
+	ret = devm_platform_probe_helper_irq(op, d, NULL,
+		zx_dma_int_handler, 0, DRIVER_NAME, d);
+	if (ret < 0)
+		return ret;
 
 	of_property_read_u32((&op->dev)->of_node,
 			     "dma-channels", &d->dma_channels);
@@ -776,18 +774,6 @@ static int zx_dma_probe(struct platform_device *op)
 	if (!d->dma_requests || !d->dma_channels)
 		return -EINVAL;
 
-	d->clk = devm_clk_get(&op->dev, NULL);
-	if (IS_ERR(d->clk)) {
-		dev_err(&op->dev, "no dma clk\n");
-		return PTR_ERR(d->clk);
-	}
-
-	d->irq = platform_get_irq(op, 0);
-	ret = devm_request_irq(&op->dev, d->irq, zx_dma_int_handler,
-			       0, DRIVER_NAME, d);
-	if (ret)
-		return ret;
-
 	/* A DMA memory pool for LLIs, align on 32-byte boundary */
 	d->pool = dmam_pool_create(DRIVER_NAME, &op->dev,
 			LLI_BLOCK_SIZE, 32, 0);
@@ -894,7 +880,6 @@ static int zx_dma_remove(struct platform_device *op)
 		list_del(&c->vc.chan.device_node);
 	}
 	clk_disable_unprepare(d->clk);
-	dmam_pool_destroy(d->pool);
 
 	return 0;
 }
-- 
2.17.1


  parent reply	other threads:[~2019-09-15  7:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15  7:00 [PATCH 0/9] added helper macros to remove duplicate code from probe functions of the platform drivers Satendra Singh Thakur
2019-09-15  7:26 ` [PATCH 1/9] probe/dma : added helper macros to remove redundant/duplicate code from probe functions of the dma controller drivers Satendra Singh Thakur
2019-09-15  7:29   ` [PATCH 2/9] probe/dma/jz4740: removed redundant code from jz4740 dma controller's probe function Satendra Singh Thakur
2019-09-15  7:29   ` Satendra Singh Thakur [this message]
2019-09-15  7:30   ` [PATCH 4/9] probe/dma/qcom-bam: removed redundant code from qcom bam " Satendra Singh Thakur
2019-09-15  7:30   ` [PATCH 5/9] probe/dma/mtk-hs: removed redundant code from mediatek hs " Satendra Singh Thakur
2019-09-15  7:31   ` [PATCH 6/9] probe/dma/sun6i: removed redundant code from sun6i " Satendra Singh Thakur
2019-09-15  7:32   ` [PATCH 7/9] probe/dma/sun4i: removed redundant code from sun4i " Satendra Singh Thakur
2019-09-15  7:32   ` [PATCH 8/9] probe/dma/axi: removed redundant code from axi " Satendra Singh Thakur
2019-09-15  7:32   ` [PATCH 9/9] probe/dma/owl: removed redundant code from owl " Satendra Singh Thakur
2019-09-18 10:27 ` [PATCH 0/9] added helper macros to remove duplicate code from probe functions of the platform drivers Vinod Koul
2019-09-21 14:57   ` Satendra Singh Thakur
2019-09-24 19:27     ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190915072938.23610-1-sst2005@gmail.com \
    --to=sst2005@gmail.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=jun.nie@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=satendrasingh.thakur@hcl.com \
    --cc=shawnguo@kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).