From 669da30d4c972fe62e14a435abf909d19d9b9467 Mon Sep 17 00:00:00 2001 From: Tushar Behera Date: Thu, 24 Jan 2013 15:41:06 +0530 Subject: i2c: s3c2410: Remove unnecessary label err_noclk 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 Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-s3c2410.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/i2c/busses/i2c-s3c2410.c') diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index a290d089ceaf..b7ca1f49d548 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; } -- cgit v1.2.3 From 2b255b947f39d9360662abf6667957add6064646 Mon Sep 17 00:00:00 2001 From: Tushar Behera Date: Thu, 24 Jan 2013 15:41:07 +0530 Subject: i2c: s3c2410: Convert to use devm_* APIs 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 Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-s3c2410.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'drivers/i2c/busses/i2c-s3c2410.c') diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index b7ca1f49d548..4b6cc130eb71 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); -- cgit v1.2.3 From d16933b33914a6dff38a4ecbe8edce44a17898e8 Mon Sep 17 00:00:00 2001 From: Tushar Behera Date: Thu, 24 Jan 2013 15:41:08 +0530 Subject: 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 Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-s3c2410.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'drivers/i2c/busses/i2c-s3c2410.c') 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) 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; } -- cgit v1.2.3 From dc6fea4456aeadd3452638668101f269fbb9fd0d Mon Sep 17 00:00:00 2001 From: Tushar Behera Date: Thu, 24 Jan 2013 15:41:09 +0530 Subject: i2c: s3c2410: Remove err_cpufreq label 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 Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-s3c2410.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/i2c/busses/i2c-s3c2410.c') diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 4d1ba8d7d347..3479ca76d2ae 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 -- cgit v1.2.3 From faf93ff6ed5f6406ca51ec6d60f85fa166fe545c Mon Sep 17 00:00:00 2001 From: Giridhar Maruthy Date: Thu, 24 Jan 2013 11:27:51 -0800 Subject: i2c: s3c2410: Add quirk to exclude GPIO config for exynos5440 Signed-off-by: Giridhar Maruthy Signed-off-by: Kukjin Kim Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-s3c2410.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/i2c/busses/i2c-s3c2410.c') diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 3479ca76d2ae..5e33df7c6c82 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -111,6 +111,8 @@ static const struct of_device_id s3c24xx_i2c_match[] = { { .compatible = "samsung,s3c2440-i2c", .data = (void *)QUIRK_S3C2440 }, { .compatible = "samsung,s3c2440-hdmiphy-i2c", .data = (void *)(QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO) }, + { .compatible = "samsung,exynos5440-i2c", + .data = (void *)(QUIRK_S3C2440 | QUIRK_NO_GPIO) }, {}, }; MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match); -- cgit v1.2.3