linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup
@ 2012-11-23  5:59 Tushar Behera
  2012-11-23  5:59 ` [PATCH 1/7] i2c: s3c2410: Remove unnecessary label err_noclk Tushar Behera
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  5:59 UTC (permalink / raw)
  To: linux-kernel, linux-i2c, linux-samsung-soc; +Cc: w.sang, kgene.kim, patches

This patchset cleans up the probe function of i2c-s3c2410 driver.
These have been tested on Exynos4210 based Origen board.

Tushar Behera (7):
  i2c: s3c2410: Remove unnecessary label err_noclk
  i2c: s3c2410: Convert to use devm_clk_get()
  i2c: s3c2410: Convert to use devm_request_mem_region()
  i2c: s3c2410: Convert to use devm_ioremap()
  i2c: s3c2410: Convert to use devm_request_irq()
  i2c: s3c2410: Move location of clk_prepare_enable() call in probe
    function
  i2c: s3c2410: Remove err_cpufreq label

 drivers/i2c/busses/i2c-s3c2410.c |   74 ++++++++++++--------------------------
 1 files changed, 23 insertions(+), 51 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/7] i2c: s3c2410: Remove unnecessary label err_noclk
  2012-11-23  5:59 [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
@ 2012-11-23  5:59 ` Tushar Behera
  2012-11-23  5:59 ` [PATCH 2/7] i2c: s3c2410: Convert to use devm_clk_get() Tushar Behera
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  5:59 UTC (permalink / raw)
  To: linux-kernel, linux-i2c, linux-samsung-soc; +Cc: w.sang, kgene.kim, patches

err_noclk label redirects to a simple return statement. Move the
return statement to the caller location and remove the label.

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
 drivers/i2c/busses/i2c-s3c2410.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 3e0335f..7522f40 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -945,8 +945,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
 	i2c->pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
 	if (!i2c->pdata) {
-		ret = -ENOMEM;
-		goto err_noclk;
+		dev_err(&pdev->dev, "no memory for platform data\n");
+		return -ENOMEM;
 	}
 
 	i2c->quirks = s3c24xx_get_device_quirks(pdev);
@@ -971,8 +971,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	i2c->clk = clk_get(&pdev->dev, "i2c");
 	if (IS_ERR(i2c->clk)) {
 		dev_err(&pdev->dev, "cannot get clock\n");
-		ret = -ENOENT;
-		goto err_noclk;
+		return -ENOENT;
 	}
 
 	dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
@@ -1084,8 +1083,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
  err_clk:
 	clk_disable_unprepare(i2c->clk);
 	clk_put(i2c->clk);
-
- err_noclk:
 	return ret;
 }
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/7] i2c: s3c2410: Convert to use devm_clk_get()
  2012-11-23  5:59 [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
  2012-11-23  5:59 ` [PATCH 1/7] i2c: s3c2410: Remove unnecessary label err_noclk Tushar Behera
@ 2012-11-23  5:59 ` Tushar Behera
  2012-11-23  5:59 ` [PATCH 4/7] i2c: s3c2410: Convert to use devm_ioremap() Tushar Behera
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  5:59 UTC (permalink / raw)
  To: linux-kernel, linux-i2c, linux-samsung-soc; +Cc: w.sang, kgene.kim, patches

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
 drivers/i2c/busses/i2c-s3c2410.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 7522f40..019c3d7 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -968,7 +968,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	/* find the clock and enable it */
 
 	i2c->dev = &pdev->dev;
-	i2c->clk = clk_get(&pdev->dev, "i2c");
+	i2c->clk = devm_clk_get(&pdev->dev, "i2c");
 	if (IS_ERR(i2c->clk)) {
 		dev_err(&pdev->dev, "cannot get clock\n");
 		return -ENOENT;
@@ -1082,7 +1082,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
  err_clk:
 	clk_disable_unprepare(i2c->clk);
-	clk_put(i2c->clk);
 	return ret;
 }
 
@@ -1104,7 +1103,6 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
 	free_irq(i2c->irq, i2c);
 
 	clk_disable_unprepare(i2c->clk);
-	clk_put(i2c->clk);
 
 	iounmap(i2c->regs);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/7] i2c: s3c2410: Convert to use devm_request_mem_region()
       [not found] ` <1353650353-17576-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2012-11-23  5:59   ` Tushar Behera
  2012-11-23  5:59   ` [PATCH 7/7] i2c: s3c2410: Remove err_cpufreq label Tushar Behera
  2012-11-23  6:15   ` [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup Shubhrajyoti Datta
  2 siblings, 0 replies; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  5:59 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA
  Cc: w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ,
	patches-QSEj5FYQhm4dnm+yROfE0A

Signed-off-by: Tushar Behera <tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/i2c/busses/i2c-s3c2410.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 019c3d7..a274ef7 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -987,8 +987,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	i2c->ioarea = request_mem_region(res->start, resource_size(res),
-					 pdev->name);
+	i2c->ioarea = devm_request_mem_region(&pdev->dev, res->start,
+					      resource_size(res), pdev->name);
 
 	if (i2c->ioarea == NULL) {
 		dev_err(&pdev->dev, "cannot request IO\n");
@@ -1001,7 +1001,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	if (i2c->regs == NULL) {
 		dev_err(&pdev->dev, "cannot map IO\n");
 		ret = -ENXIO;
-		goto err_ioarea;
+		goto err_clk;
 	}
 
 	dev_dbg(&pdev->dev, "registers %p (%p, %p)\n",
@@ -1076,10 +1076,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
  err_iomap:
 	iounmap(i2c->regs);
 
- err_ioarea:
-	release_resource(i2c->ioarea);
-	kfree(i2c->ioarea);
-
  err_clk:
 	clk_disable_unprepare(i2c->clk);
 	return ret;
@@ -1106,9 +1102,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
 
 	iounmap(i2c->regs);
 
-	release_resource(i2c->ioarea);
 	s3c24xx_i2c_dt_gpio_free(i2c);
-	kfree(i2c->ioarea);
 
 	return 0;
 }
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/7] i2c: s3c2410: Convert to use devm_ioremap()
  2012-11-23  5:59 [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
  2012-11-23  5:59 ` [PATCH 1/7] i2c: s3c2410: Remove unnecessary label err_noclk Tushar Behera
  2012-11-23  5:59 ` [PATCH 2/7] i2c: s3c2410: Convert to use devm_clk_get() Tushar Behera
@ 2012-11-23  5:59 ` Tushar Behera
       [not found]   ` <1353650353-17576-5-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  2012-11-23  5:59 ` [PATCH 5/7] i2c: s3c2410: Convert to use devm_request_irq() Tushar Behera
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  5:59 UTC (permalink / raw)
  To: linux-kernel, linux-i2c, linux-samsung-soc; +Cc: w.sang, kgene.kim, patches

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
 drivers/i2c/busses/i2c-s3c2410.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index a274ef7..3446af2 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -996,7 +996,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	i2c->regs = ioremap(res->start, resource_size(res));
+	i2c->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
 
 	if (i2c->regs == NULL) {
 		dev_err(&pdev->dev, "cannot map IO\n");
@@ -1016,7 +1016,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
 	ret = s3c24xx_i2c_init(i2c);
 	if (ret != 0)
-		goto err_iomap;
+		goto err_clk;
 
 	/* find the IRQ for this unit (note, this relies on the init call to
 	 * ensure no current IRQs pending
@@ -1025,7 +1025,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	i2c->irq = ret = platform_get_irq(pdev, 0);
 	if (ret <= 0) {
 		dev_err(&pdev->dev, "cannot find IRQ\n");
-		goto err_iomap;
+		goto err_clk;
 	}
 
 	ret = request_irq(i2c->irq, s3c24xx_i2c_irq, 0,
@@ -1033,7 +1033,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
 	if (ret != 0) {
 		dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
-		goto err_iomap;
+		goto err_clk;
 	}
 
 	ret = s3c24xx_i2c_register_cpufreq(i2c);
@@ -1073,9 +1073,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
  err_irq:
 	free_irq(i2c->irq, i2c);
 
- err_iomap:
-	iounmap(i2c->regs);
-
  err_clk:
 	clk_disable_unprepare(i2c->clk);
 	return ret;
@@ -1100,8 +1097,6 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(i2c->clk);
 
-	iounmap(i2c->regs);
-
 	s3c24xx_i2c_dt_gpio_free(i2c);
 
 	return 0;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/7] i2c: s3c2410: Convert to use devm_request_irq()
  2012-11-23  5:59 [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
                   ` (2 preceding siblings ...)
  2012-11-23  5:59 ` [PATCH 4/7] i2c: s3c2410: Convert to use devm_ioremap() Tushar Behera
@ 2012-11-23  5:59 ` Tushar Behera
  2012-11-23  5:59 ` [PATCH 6/7] i2c: s3c2410: Move location of clk_prepare_enable() call in probe function Tushar Behera
       [not found] ` <1353650353-17576-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  5 siblings, 0 replies; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  5:59 UTC (permalink / raw)
  To: linux-kernel, linux-i2c, linux-samsung-soc; +Cc: w.sang, kgene.kim, patches

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
 drivers/i2c/busses/i2c-s3c2410.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 3446af2..3e4143c 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1028,8 +1028,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	ret = request_irq(i2c->irq, s3c24xx_i2c_irq, 0,
-			  dev_name(&pdev->dev), i2c);
+	ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0,
+			       dev_name(&pdev->dev), i2c);
 
 	if (ret != 0) {
 		dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
@@ -1039,7 +1039,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	ret = s3c24xx_i2c_register_cpufreq(i2c);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
-		goto err_irq;
+		goto err_clk;
 	}
 
 	/* Note, previous versions of the driver used i2c_add_adapter()
@@ -1070,9 +1070,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
  err_cpufreq:
 	s3c24xx_i2c_deregister_cpufreq(i2c);
 
- err_irq:
-	free_irq(i2c->irq, i2c);
-
  err_clk:
 	clk_disable_unprepare(i2c->clk);
 	return ret;
@@ -1093,7 +1090,6 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
 	s3c24xx_i2c_deregister_cpufreq(i2c);
 
 	i2c_del_adapter(&i2c->adap);
-	free_irq(i2c->irq, i2c);
 
 	clk_disable_unprepare(i2c->clk);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/7] i2c: s3c2410: Move location of clk_prepare_enable() call in probe function
  2012-11-23  5:59 [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
                   ` (3 preceding siblings ...)
  2012-11-23  5:59 ` [PATCH 5/7] i2c: s3c2410: Convert to use devm_request_irq() Tushar Behera
@ 2012-11-23  5:59 ` Tushar Behera
       [not found] ` <1353650353-17576-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  5 siblings, 0 replies; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  5:59 UTC (permalink / raw)
  To: linux-kernel, linux-i2c, linux-samsung-soc; +Cc: w.sang, kgene.kim, patches

In probe call, only s3c24xx_i2c_init() needs the I2C clock to be enabled.
Moving clk_prepare_enable() and clk_disable_unprepare() calls to around
this function simplifies the return path of probe call.

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---
 drivers/i2c/busses/i2c-s3c2410.c |   29 ++++++++++++-----------------
 1 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 3e4143c..707efaf 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -976,15 +976,13 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
 
-	clk_prepare_enable(i2c->clk);
 
 	/* map the registers */
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (res == NULL) {
 		dev_err(&pdev->dev, "cannot find IO resource\n");
-		ret = -ENOENT;
-		goto err_clk;
+		return -ENOENT;
 	}
 
 	i2c->ioarea = devm_request_mem_region(&pdev->dev, res->start,
@@ -992,16 +990,14 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
 	if (i2c->ioarea == NULL) {
 		dev_err(&pdev->dev, "cannot request IO\n");
-		ret = -ENXIO;
-		goto err_clk;
+		return -ENXIO;
 	}
 
 	i2c->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
 
 	if (i2c->regs == NULL) {
 		dev_err(&pdev->dev, "cannot map IO\n");
-		ret = -ENXIO;
-		goto err_clk;
+		return -ENXIO;
 	}
 
 	dev_dbg(&pdev->dev, "registers %p (%p, %p)\n",
@@ -1014,10 +1010,13 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
 	/* initialise the i2c controller */
 
+	clk_prepare_enable(i2c->clk);
 	ret = s3c24xx_i2c_init(i2c);
-	if (ret != 0)
-		goto err_clk;
-
+	clk_disable_unprepare(i2c->clk);
+	if (ret != 0) {
+		dev_err(&pdev->dev, "I2C controller init failed\n");
+		return ret;
+	}
 	/* find the IRQ for this unit (note, this relies on the init call to
 	 * ensure no current IRQs pending
 	 */
@@ -1025,7 +1024,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	i2c->irq = ret = platform_get_irq(pdev, 0);
 	if (ret <= 0) {
 		dev_err(&pdev->dev, "cannot find IRQ\n");
-		goto err_clk;
+		return ret;
 	}
 
 	ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0,
@@ -1033,13 +1032,13 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
 	if (ret != 0) {
 		dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
-		goto err_clk;
+		return ret;
 	}
 
 	ret = s3c24xx_i2c_register_cpufreq(i2c);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
-		goto err_clk;
+		return ret;
 	}
 
 	/* Note, previous versions of the driver used i2c_add_adapter()
@@ -1064,14 +1063,10 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	pm_runtime_enable(&i2c->adap.dev);
 
 	dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
-	clk_disable_unprepare(i2c->clk);
 	return 0;
 
  err_cpufreq:
 	s3c24xx_i2c_deregister_cpufreq(i2c);
-
- err_clk:
-	clk_disable_unprepare(i2c->clk);
 	return ret;
 }
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/7] i2c: s3c2410: Remove err_cpufreq label
       [not found] ` <1353650353-17576-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  2012-11-23  5:59   ` [PATCH 3/7] i2c: s3c2410: Convert to use devm_request_mem_region() Tushar Behera
@ 2012-11-23  5:59   ` Tushar Behera
  2012-11-23  6:15   ` [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup Shubhrajyoti Datta
  2 siblings, 0 replies; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  5:59 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA
  Cc: w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ,
	patches-QSEj5FYQhm4dnm+yROfE0A

err_cpufreq label is now used only once. It can be removed and related
code can be moved to the caller location.

Signed-off-by: Tushar Behera <tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/i2c/busses/i2c-s3c2410.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 707efaf..c934ec8 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1053,7 +1053,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	ret = i2c_add_numbered_adapter(&i2c->adap);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to add bus to i2c core\n");
-		goto err_cpufreq;
+		s3c24xx_i2c_deregister_cpufreq(i2c);
+		return ret;
 	}
 
 	of_i2c_register_devices(&i2c->adap);
@@ -1064,10 +1065,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
 	dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
 	return 0;
-
- err_cpufreq:
-	s3c24xx_i2c_deregister_cpufreq(i2c);
-	return ret;
 }
 
 /* s3c24xx_i2c_remove
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/7] i2c: s3c2410: Convert to use devm_ioremap()
       [not found]   ` <1353650353-17576-5-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2012-11-23  6:14     ` Sachin Kamat
  2012-11-23  6:43       ` Tushar Behera
  0 siblings, 1 reply; 12+ messages in thread
From: Sachin Kamat @ 2012-11-23  6:14 UTC (permalink / raw)
  To: Tushar Behera
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ,
	patches-QSEj5FYQhm4dnm+yROfE0A

Hi Tushar,

On 23 November 2012 11:29, Tushar Behera <tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> Signed-off-by: Tushar Behera <tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-s3c2410.c |   13 ++++---------
>  1 files changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index a274ef7..3446af2 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -996,7 +996,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>                 goto err_clk;
>         }
>
> -       i2c->regs = ioremap(res->start, resource_size(res));
> +       i2c->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
>

request_mem_region and ioremap and be replaced using a single
devm_request_and_ioremap() call.

Also you may squash patches 2-5 into single convert to devm_* functions patch.


>         if (i2c->regs == NULL) {
>                 dev_err(&pdev->dev, "cannot map IO\n");
> @@ -1016,7 +1016,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>
>         ret = s3c24xx_i2c_init(i2c);
>         if (ret != 0)
> -               goto err_iomap;
> +               goto err_clk;
>
>         /* find the IRQ for this unit (note, this relies on the init call to
>          * ensure no current IRQs pending
> @@ -1025,7 +1025,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>         i2c->irq = ret = platform_get_irq(pdev, 0);
>         if (ret <= 0) {
>                 dev_err(&pdev->dev, "cannot find IRQ\n");
> -               goto err_iomap;
> +               goto err_clk;
>         }
>
>         ret = request_irq(i2c->irq, s3c24xx_i2c_irq, 0,
> @@ -1033,7 +1033,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>
>         if (ret != 0) {
>                 dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
> -               goto err_iomap;
> +               goto err_clk;
>         }
>
>         ret = s3c24xx_i2c_register_cpufreq(i2c);
> @@ -1073,9 +1073,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>   err_irq:
>         free_irq(i2c->irq, i2c);
>
> - err_iomap:
> -       iounmap(i2c->regs);
> -
>   err_clk:
>         clk_disable_unprepare(i2c->clk);
>         return ret;
> @@ -1100,8 +1097,6 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
>
>         clk_disable_unprepare(i2c->clk);
>
> -       iounmap(i2c->regs);
> -
>         s3c24xx_i2c_dt_gpio_free(i2c);
>
>         return 0;
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
With warm regards,
Sachin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup
       [not found] ` <1353650353-17576-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  2012-11-23  5:59   ` [PATCH 3/7] i2c: s3c2410: Convert to use devm_request_mem_region() Tushar Behera
  2012-11-23  5:59   ` [PATCH 7/7] i2c: s3c2410: Remove err_cpufreq label Tushar Behera
@ 2012-11-23  6:15   ` Shubhrajyoti Datta
       [not found]     ` <CAM=Q2cs=oYq4e17LXxUEhATiYLAjnzoTH-+nsO5KNQwGj2qSBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2 siblings, 1 reply; 12+ messages in thread
From: Shubhrajyoti Datta @ 2012-11-23  6:15 UTC (permalink / raw)
  To: Tushar Behera
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ,
	patches-QSEj5FYQhm4dnm+yROfE0A

On Fri, Nov 23, 2012 at 11:29 AM, Tushar Behera
<tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> This patchset cleans up the probe function of i2c-s3c2410 driver.
> These have been tested on Exynos4210 based Origen board.
>
> Tushar Behera (7):
>   i2c: s3c2410: Remove unnecessary label err_noclk
>   i2c: s3c2410: Convert to use devm_clk_get()
>   i2c: s3c2410: Convert to use devm_request_mem_region()
>   i2c: s3c2410: Convert to use devm_ioremap()
>   i2c: s3c2410: Convert to use devm_request_irq()

You may want to consider request_and_ioremap.


>   i2c: s3c2410: Move location of clk_prepare_enable() call in probe
>     function
>   i2c: s3c2410: Remove err_cpufreq label
>
>  drivers/i2c/busses/i2c-s3c2410.c |   74 ++++++++++++--------------------------
>  1 files changed, 23 insertions(+), 51 deletions(-)
>
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/7] i2c: s3c2410: Convert to use devm_ioremap()
  2012-11-23  6:14     ` Sachin Kamat
@ 2012-11-23  6:43       ` Tushar Behera
  0 siblings, 0 replies; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  6:43 UTC (permalink / raw)
  To: Sachin Kamat
  Cc: linux-kernel, linux-i2c, linux-samsung-soc, w.sang, kgene.kim,
	patches

On 11/23/2012 11:44 AM, Sachin Kamat wrote:
> Hi Tushar,
> 
> On 23 November 2012 11:29, Tushar Behera <tushar.behera@linaro.org> wrote:
>> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
>> ---
>>  drivers/i2c/busses/i2c-s3c2410.c |   13 ++++---------
>>  1 files changed, 4 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
>> index a274ef7..3446af2 100644
>> --- a/drivers/i2c/busses/i2c-s3c2410.c
>> +++ b/drivers/i2c/busses/i2c-s3c2410.c
>> @@ -996,7 +996,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>>                 goto err_clk;
>>         }
>>
>> -       i2c->regs = ioremap(res->start, resource_size(res));
>> +       i2c->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
>>
> 
> request_mem_region and ioremap and be replaced using a single
> devm_request_and_ioremap() call.
> 

Thanks. I will redo the patch.

> Also you may squash patches 2-5 into single convert to devm_* functions patch.
> 

Ok. In that case, I will squash these patches to a single patch.

> 
>>         if (i2c->regs == NULL) {
>>                 dev_err(&pdev->dev, "cannot map IO\n");
>> @@ -1016,7 +1016,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>>
>>         ret = s3c24xx_i2c_init(i2c);
>>         if (ret != 0)
>> -               goto err_iomap;
>> +               goto err_clk;
>>
>>         /* find the IRQ for this unit (note, this relies on the init call to
>>          * ensure no current IRQs pending
>> @@ -1025,7 +1025,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>>         i2c->irq = ret = platform_get_irq(pdev, 0);
>>         if (ret <= 0) {
>>                 dev_err(&pdev->dev, "cannot find IRQ\n");
>> -               goto err_iomap;
>> +               goto err_clk;
>>         }
>>
>>         ret = request_irq(i2c->irq, s3c24xx_i2c_irq, 0,
>> @@ -1033,7 +1033,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>>
>>         if (ret != 0) {
>>                 dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
>> -               goto err_iomap;
>> +               goto err_clk;
>>         }
>>
>>         ret = s3c24xx_i2c_register_cpufreq(i2c);
>> @@ -1073,9 +1073,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>>   err_irq:
>>         free_irq(i2c->irq, i2c);
>>
>> - err_iomap:
>> -       iounmap(i2c->regs);
>> -
>>   err_clk:
>>         clk_disable_unprepare(i2c->clk);
>>         return ret;
>> @@ -1100,8 +1097,6 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
>>
>>         clk_disable_unprepare(i2c->clk);
>>
>> -       iounmap(i2c->regs);
>> -
>>         s3c24xx_i2c_dt_gpio_free(i2c);
>>
>>         return 0;
>> --
>> 1.7.4.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 
> 


-- 
Tushar Behera

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup
       [not found]     ` <CAM=Q2cs=oYq4e17LXxUEhATiYLAjnzoTH-+nsO5KNQwGj2qSBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-11-23  6:44       ` Tushar Behera
  0 siblings, 0 replies; 12+ messages in thread
From: Tushar Behera @ 2012-11-23  6:44 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	w.sang-bIcnvbaLZ9MEGnE8C9+IrQ, kgene.kim-Sze3O3UU22JBDgjK7y7TUQ,
	patches-QSEj5FYQhm4dnm+yROfE0A

On 11/23/2012 11:45 AM, Shubhrajyoti Datta wrote:
> On Fri, Nov 23, 2012 at 11:29 AM, Tushar Behera
> <tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
>> This patchset cleans up the probe function of i2c-s3c2410 driver.
>> These have been tested on Exynos4210 based Origen board.
>>
>> Tushar Behera (7):
>>   i2c: s3c2410: Remove unnecessary label err_noclk
>>   i2c: s3c2410: Convert to use devm_clk_get()
>>   i2c: s3c2410: Convert to use devm_request_mem_region()
>>   i2c: s3c2410: Convert to use devm_ioremap()
>>   i2c: s3c2410: Convert to use devm_request_irq()
> 
> You may want to consider request_and_ioremap.
> 

Thanks. I will redo the patchset and submit again.

> 
>>   i2c: s3c2410: Move location of clk_prepare_enable() call in probe
>>     function
>>   i2c: s3c2410: Remove err_cpufreq label
>>
>>  drivers/i2c/busses/i2c-s3c2410.c |   74 ++++++++++++--------------------------
>>  1 files changed, 23 insertions(+), 51 deletions(-)
>>
>> --
>> 1.7.4.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Tushar Behera

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-11-23  6:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-23  5:59 [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
2012-11-23  5:59 ` [PATCH 1/7] i2c: s3c2410: Remove unnecessary label err_noclk Tushar Behera
2012-11-23  5:59 ` [PATCH 2/7] i2c: s3c2410: Convert to use devm_clk_get() Tushar Behera
2012-11-23  5:59 ` [PATCH 4/7] i2c: s3c2410: Convert to use devm_ioremap() Tushar Behera
     [not found]   ` <1353650353-17576-5-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-11-23  6:14     ` Sachin Kamat
2012-11-23  6:43       ` Tushar Behera
2012-11-23  5:59 ` [PATCH 5/7] i2c: s3c2410: Convert to use devm_request_irq() Tushar Behera
2012-11-23  5:59 ` [PATCH 6/7] i2c: s3c2410: Move location of clk_prepare_enable() call in probe function Tushar Behera
     [not found] ` <1353650353-17576-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-11-23  5:59   ` [PATCH 3/7] i2c: s3c2410: Convert to use devm_request_mem_region() Tushar Behera
2012-11-23  5:59   ` [PATCH 7/7] i2c: s3c2410: Remove err_cpufreq label Tushar Behera
2012-11-23  6:15   ` [PATCH 0/7] i2c: s3c2410: Add devm_* apis and cleanup Shubhrajyoti Datta
     [not found]     ` <CAM=Q2cs=oYq4e17LXxUEhATiYLAjnzoTH-+nsO5KNQwGj2qSBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-11-23  6:44       ` Tushar Behera

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).