aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorTushar Behera <tushar.behera@linaro.org>2013-01-24 05:11:08 -0500
committerWolfram Sang <w.sang@pengutronix.de>2013-01-27 23:26:44 -0500
commitd16933b33914a6dff38a4ecbe8edce44a17898e8 (patch)
tree0f66a465cd863d8acff40ae56dc3eb2ed102ec46 /drivers/i2c
parent2b255b947f39d9360662abf6667957add6064646 (diff)
i2c: s3c2410: Move location of clk_prepare_enable() call in probe function
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> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 4b6cc130eb71..4d1ba8d7d347 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)
1030 1030
1031 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); 1031 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
1032 1032
1033 clk_prepare_enable(i2c->clk);
1034 1033
1035 /* map the registers */ 1034 /* map the registers */
1036 1035
1037 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1036 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1038 if (res == NULL) { 1037 if (res == NULL) {
1039 dev_err(&pdev->dev, "cannot find IO resource\n"); 1038 dev_err(&pdev->dev, "cannot find IO resource\n");
1040 ret = -ENOENT; 1039 return -ENOENT;
1041 goto err_clk;
1042 } 1040 }
1043 1041
1044 i2c->regs = devm_request_and_ioremap(&pdev->dev, res); 1042 i2c->regs = devm_request_and_ioremap(&pdev->dev, res);
1045 1043
1046 if (i2c->regs == NULL) { 1044 if (i2c->regs == NULL) {
1047 dev_err(&pdev->dev, "cannot request and map IO\n"); 1045 dev_err(&pdev->dev, "cannot request and map IO\n");
1048 ret = -ENXIO; 1046 return -ENXIO;
1049 goto err_clk;
1050 } 1047 }
1051 1048
1052 dev_dbg(&pdev->dev, "registers %p (%p)\n", 1049 dev_dbg(&pdev->dev, "registers %p (%p)\n",
@@ -1064,16 +1061,18 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
1064 if (i2c->pdata->cfg_gpio) { 1061 if (i2c->pdata->cfg_gpio) {
1065 i2c->pdata->cfg_gpio(to_platform_device(i2c->dev)); 1062 i2c->pdata->cfg_gpio(to_platform_device(i2c->dev));
1066 } else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) { 1063 } else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) {
1067 ret = -EINVAL; 1064 return -EINVAL;
1068 goto err_clk;
1069 } 1065 }
1070 1066
1071 /* initialise the i2c controller */ 1067 /* initialise the i2c controller */
1072 1068
1069 clk_prepare_enable(i2c->clk);
1073 ret = s3c24xx_i2c_init(i2c); 1070 ret = s3c24xx_i2c_init(i2c);
1074 if (ret != 0) 1071 clk_disable_unprepare(i2c->clk);
1075 goto err_clk; 1072 if (ret != 0) {
1076 1073 dev_err(&pdev->dev, "I2C controller init failed\n");
1074 return ret;
1075 }
1077 /* find the IRQ for this unit (note, this relies on the init call to 1076 /* find the IRQ for this unit (note, this relies on the init call to
1078 * ensure no current IRQs pending 1077 * ensure no current IRQs pending
1079 */ 1078 */
@@ -1081,7 +1080,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
1081 i2c->irq = ret = platform_get_irq(pdev, 0); 1080 i2c->irq = ret = platform_get_irq(pdev, 0);
1082 if (ret <= 0) { 1081 if (ret <= 0) {
1083 dev_err(&pdev->dev, "cannot find IRQ\n"); 1082 dev_err(&pdev->dev, "cannot find IRQ\n");
1084 goto err_clk; 1083 return ret;
1085 } 1084 }
1086 1085
1087 ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0, 1086 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)
1089 1088
1090 if (ret != 0) { 1089 if (ret != 0) {
1091 dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); 1090 dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
1092 goto err_clk; 1091 return ret;
1093 } 1092 }
1094 1093
1095 ret = s3c24xx_i2c_register_cpufreq(i2c); 1094 ret = s3c24xx_i2c_register_cpufreq(i2c);
1096 if (ret < 0) { 1095 if (ret < 0) {
1097 dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); 1096 dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
1098 goto err_clk; 1097 return ret;
1099 } 1098 }
1100 1099
1101 /* Note, previous versions of the driver used i2c_add_adapter() 1100 /* Note, previous versions of the driver used i2c_add_adapter()
@@ -1120,14 +1119,10 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
1120 pm_runtime_enable(&i2c->adap.dev); 1119 pm_runtime_enable(&i2c->adap.dev);
1121 1120
1122 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev)); 1121 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
1123 clk_disable_unprepare(i2c->clk);
1124 return 0; 1122 return 0;
1125 1123
1126 err_cpufreq: 1124 err_cpufreq:
1127 s3c24xx_i2c_deregister_cpufreq(i2c); 1125 s3c24xx_i2c_deregister_cpufreq(i2c);
1128
1129 err_clk:
1130 clk_disable_unprepare(i2c->clk);
1131 return ret; 1126 return ret;
1132} 1127}
1133 1128