* [PATCH V3 0/4] i2c: s3c2410: Add devm_* apis and cleanup
@ 2013-01-24 10:11 Tushar Behera
2013-01-24 10:11 ` [PATCH V3 1/4] i2c: s3c2410: Remove unnecessary label err_noclk Tushar Behera
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Tushar Behera @ 2013-01-24 10:11 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
This patchset cleans up the probe function of i2c-s3c2410 driver.
These have been tested on Exynos4210 based Origen board.
Changes since V2:
* Rebased to v3.8-rc4.
* devm_request_and_ioremap() has already been implemented.
Changes since V1:
* devm_request_mem_region and devm_ioremap calls were replaced by
devm_request_and_ioremap() call.
* All devm_* related modifications (earlier patches 2-5) were merged
to a single patch.
Tushar Behera (4):
i2c: s3c2410: Remove unnecessary label err_noclk
i2c: s3c2410: Convert to use devm_* APIs
i2c: s3c2410: Move location of clk_prepare_enable() call in probe
function
i2c: s3c2410: Remove err_cpufreq label
drivers/i2c/busses/i2c-s3c2410.c | 59 +++++++++++++------------------------
1 files changed, 21 insertions(+), 38 deletions(-)
--
1.7.4.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH V3 1/4] i2c: s3c2410: Remove unnecessary label err_noclk
2013-01-24 10:11 [PATCH V3 0/4] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
@ 2013-01-24 10:11 ` Tushar Behera
[not found] ` <1359022269-12593-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Tushar Behera @ 2013-01-24 10:11 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>
---
Changes since V2:
* Rebased to v3.8-rc4.
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 a290d08..b7ca1f4 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1000,8 +1000,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);
@@ -1025,8 +1025,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);
@@ -1133,8 +1132,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] 5+ messages in thread
* [PATCH V3 2/4] i2c: s3c2410: Convert to use devm_* APIs
[not found] ` <1359022269-12593-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2013-01-24 10:11 ` Tushar Behera
0 siblings, 0 replies; 5+ messages in thread
From: Tushar Behera @ 2013-01-24 10:11 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
i2c-s3c2410 driver is modified to use devm_clk_get()
and devm_request_irq(). This also simplifies the
return path in driver's probe.
Signed-off-by: Tushar Behera <tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
Changes since V2:
* Rebased on v3.8-rc4. devm_request_and_ioremap implementaion
has already been merged.
Changes since V1:
* devm_request_mem_region and devm_ioremap calls were replaced by
devm_request_and_ioremap() call.
* All devm_* related modifications (earlier patches 2-5) were merged
to a single patch.
drivers/i2c/busses/i2c-s3c2410.c | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index b7ca1f4..4b6cc13 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1022,7 +1022,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;
@@ -1044,7 +1044,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
i2c->regs = devm_request_and_ioremap(&pdev->dev, res);
if (i2c->regs == NULL) {
- dev_err(&pdev->dev, "cannot map IO\n");
+ dev_err(&pdev->dev, "cannot request and map IO\n");
ret = -ENXIO;
goto err_clk;
}
@@ -1084,8 +1084,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);
@@ -1095,7 +1095,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()
@@ -1126,12 +1126,8 @@ 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);
- clk_put(i2c->clk);
return ret;
}
@@ -1150,10 +1146,8 @@ 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);
- clk_put(i2c->clk);
if (pdev->dev.of_node && IS_ERR(i2c->pctrl))
s3c24xx_i2c_dt_gpio_free(i2c);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH V3 3/4] i2c: s3c2410: Move location of clk_prepare_enable() call in probe function
2013-01-24 10:11 [PATCH V3 0/4] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
2013-01-24 10:11 ` [PATCH V3 1/4] i2c: s3c2410: Remove unnecessary label err_noclk Tushar Behera
[not found] ` <1359022269-12593-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2013-01-24 10:11 ` Tushar Behera
2013-01-24 10:11 ` [PATCH V3 4/4] i2c: s3c2410: Remove err_cpufreq label Tushar Behera
3 siblings, 0 replies; 5+ messages in thread
From: Tushar Behera @ 2013-01-24 10:11 UTC (permalink / raw)
To: linux-kernel, linux-i2c, linux-samsung-soc; +Cc: w.sang, kgene.kim, patches
In i2c-s3c2410 driver probe, 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>
---
Changes since V2:
* Rebased to v3.8-rc4.
Changes since V1:
* Rebased as per the V2 patch series.
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 4b6cc13..4d1ba8d 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1030,23 +1030,20 @@ 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->regs = devm_request_and_ioremap(&pdev->dev, res);
if (i2c->regs == NULL) {
dev_err(&pdev->dev, "cannot request and map IO\n");
- ret = -ENXIO;
- goto err_clk;
+ return -ENXIO;
}
dev_dbg(&pdev->dev, "registers %p (%p)\n",
@@ -1064,16 +1061,18 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
if (i2c->pdata->cfg_gpio) {
i2c->pdata->cfg_gpio(to_platform_device(i2c->dev));
} else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) {
- ret = -EINVAL;
- goto err_clk;
+ return -EINVAL;
}
/* 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
*/
@@ -1081,7 +1080,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,
@@ -1089,13 +1088,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()
@@ -1120,14 +1119,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] 5+ messages in thread
* [PATCH V3 4/4] i2c: s3c2410: Remove err_cpufreq label
2013-01-24 10:11 [PATCH V3 0/4] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
` (2 preceding siblings ...)
2013-01-24 10:11 ` [PATCH V3 3/4] i2c: s3c2410: Move location of clk_prepare_enable() call in probe function Tushar Behera
@ 2013-01-24 10:11 ` Tushar Behera
3 siblings, 0 replies; 5+ messages in thread
From: Tushar Behera @ 2013-01-24 10:11 UTC (permalink / raw)
To: linux-kernel, linux-i2c, linux-samsung-soc; +Cc: w.sang, kgene.kim, patches
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@linaro.org>
---
Changes since V2:
* Rebased to v3.8-rc4.
Changes since V1:
* Rebased as per the V2 patch series.
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 4d1ba8d..3479ca7 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1109,7 +1109,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);
@@ -1120,10 +1121,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] 5+ messages in thread
end of thread, other threads:[~2013-01-24 10:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-24 10:11 [PATCH V3 0/4] i2c: s3c2410: Add devm_* apis and cleanup Tushar Behera
2013-01-24 10:11 ` [PATCH V3 1/4] i2c: s3c2410: Remove unnecessary label err_noclk Tushar Behera
[not found] ` <1359022269-12593-1-git-send-email-tushar.behera-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-01-24 10:11 ` [PATCH V3 2/4] i2c: s3c2410: Convert to use devm_* APIs Tushar Behera
2013-01-24 10:11 ` [PATCH V3 3/4] i2c: s3c2410: Move location of clk_prepare_enable() call in probe function Tushar Behera
2013-01-24 10:11 ` [PATCH V3 4/4] i2c: s3c2410: Remove err_cpufreq label 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).