Commit d16933b3 authored by Tushar Behera's avatar Tushar Behera Committed by Wolfram Sang

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: default avatarTushar Behera <tushar.behera@linaro.org>
Signed-off-by: default avatarWolfram Sang <w.sang@pengutronix.de>
parent 2b255b94
...@@ -1030,23 +1030,20 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) ...@@ -1030,23 +1030,20 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
clk_prepare_enable(i2c->clk);
/* map the registers */ /* map the registers */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) { if (res == NULL) {
dev_err(&pdev->dev, "cannot find IO resource\n"); dev_err(&pdev->dev, "cannot find IO resource\n");
ret = -ENOENT; return -ENOENT;
goto err_clk;
} }
i2c->regs = devm_request_and_ioremap(&pdev->dev, res); i2c->regs = devm_request_and_ioremap(&pdev->dev, res);
if (i2c->regs == NULL) { if (i2c->regs == NULL) {
dev_err(&pdev->dev, "cannot request and map IO\n"); dev_err(&pdev->dev, "cannot request and map IO\n");
ret = -ENXIO; return -ENXIO;
goto err_clk;
} }
dev_dbg(&pdev->dev, "registers %p (%p)\n", dev_dbg(&pdev->dev, "registers %p (%p)\n",
...@@ -1064,16 +1061,18 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) ...@@ -1064,16 +1061,18 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
if (i2c->pdata->cfg_gpio) { if (i2c->pdata->cfg_gpio) {
i2c->pdata->cfg_gpio(to_platform_device(i2c->dev)); i2c->pdata->cfg_gpio(to_platform_device(i2c->dev));
} else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) { } else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) {
ret = -EINVAL; return -EINVAL;
goto err_clk;
} }
/* initialise the i2c controller */ /* initialise the i2c controller */
clk_prepare_enable(i2c->clk);
ret = s3c24xx_i2c_init(i2c); ret = s3c24xx_i2c_init(i2c);
if (ret != 0) clk_disable_unprepare(i2c->clk);
goto err_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 /* find the IRQ for this unit (note, this relies on the init call to
* ensure no current IRQs pending * ensure no current IRQs pending
*/ */
...@@ -1081,7 +1080,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) ...@@ -1081,7 +1080,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
i2c->irq = ret = platform_get_irq(pdev, 0); i2c->irq = ret = platform_get_irq(pdev, 0);
if (ret <= 0) { if (ret <= 0) {
dev_err(&pdev->dev, "cannot find IRQ\n"); 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, 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,13 +1088,13 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
goto err_clk; return ret;
} }
ret = s3c24xx_i2c_register_cpufreq(i2c); ret = s3c24xx_i2c_register_cpufreq(i2c);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); 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() /* Note, previous versions of the driver used i2c_add_adapter()
...@@ -1120,14 +1119,10 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) ...@@ -1120,14 +1119,10 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
pm_runtime_enable(&i2c->adap.dev); pm_runtime_enable(&i2c->adap.dev);
dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev)); dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
clk_disable_unprepare(i2c->clk);
return 0; return 0;
err_cpufreq: err_cpufreq:
s3c24xx_i2c_deregister_cpufreq(i2c); s3c24xx_i2c_deregister_cpufreq(i2c);
err_clk:
clk_disable_unprepare(i2c->clk);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment