linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Satendra Singh Thakur <sst2005@gmail.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>,
	Chen-Yu Tsai <wens@csie.org>,
	linux-kernel@vger.kernel.org, Vinod Koul <vkoul@kernel.org>,
	satendrasingh.thakur@hcl.com, dmaengine@vger.kernel.org,
	Dan Williams <dan.j.williams@intel.com>,
	Satendra Singh Thakur <sst2005@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/9] probe/dma/sun4i: removed redundant code from sun4i dma controller's probe function
Date: Sun, 15 Sep 2019 13:02:00 +0530	[thread overview]
Message-ID: <20190915073201.24032-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
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@hcl.com>
Signed-off-by: Satendra Singh Thakur <sst2005@gmail.com>
---
 drivers/dma/sun4i-dma.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c
index 1f80568b2613..5db139ff43ac 100644
--- a/drivers/dma/sun4i-dma.c
+++ b/drivers/dma/sun4i-dma.c
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/probe-helper.h>
 
 #include "virt-dma.h"
 
@@ -1119,29 +1120,16 @@ static irqreturn_t sun4i_dma_interrupt(int irq, void *dev_id)
 static int sun4i_dma_probe(struct platform_device *pdev)
 {
 	struct sun4i_dma_dev *priv;
-	struct resource *res;
 	int i, j, ret;
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->base = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(priv->base))
-		return PTR_ERR(priv->base);
-
-	priv->irq = platform_get_irq(pdev, 0);
-	if (priv->irq < 0) {
-		dev_err(&pdev->dev, "Cannot claim IRQ\n");
-		return priv->irq;
-	}
-
-	priv->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(priv->clk)) {
-		dev_err(&pdev->dev, "No clock specified\n");
-		return PTR_ERR(priv->clk);
-	}
+	/*
+	 * 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, priv, NULL);
+	if (ret < 0)
+		return ret;
 
 	platform_set_drvdata(pdev, priv);
 	spin_lock_init(&priv->lock);
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

Thread overview: 10+ 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 3/9] probe/dma/zx: removed redundant code from zx dma controller's probe function 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   ` Satendra Singh Thakur [this message]
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=20190915073201.24032-1-sst2005@gmail.com \
    --to=sst2005@gmail.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=satendrasingh.thakur@hcl.com \
    --cc=vkoul@kernel.org \
    --cc=wens@csie.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).