diff options
author | Tushar Behera <tushar.behera@linaro.org> | 2013-01-24 05:11:07 -0500 |
---|---|---|
committer | Wolfram Sang <w.sang@pengutronix.de> | 2013-01-27 23:26:44 -0500 |
commit | 2b255b947f39d9360662abf6667957add6064646 (patch) | |
tree | a98080692b10f0b6dce72d0828c0eb5e746698ac /drivers/i2c/busses | |
parent | 669da30d4c972fe62e14a435abf909d19d9b9467 (diff) |
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 <tushar.behera@linaro.org>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r-- | 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 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) | |||
1022 | /* find the clock and enable it */ | 1022 | /* find the clock and enable it */ |
1023 | 1023 | ||
1024 | i2c->dev = &pdev->dev; | 1024 | i2c->dev = &pdev->dev; |
1025 | i2c->clk = clk_get(&pdev->dev, "i2c"); | 1025 | i2c->clk = devm_clk_get(&pdev->dev, "i2c"); |
1026 | if (IS_ERR(i2c->clk)) { | 1026 | if (IS_ERR(i2c->clk)) { |
1027 | dev_err(&pdev->dev, "cannot get clock\n"); | 1027 | dev_err(&pdev->dev, "cannot get clock\n"); |
1028 | return -ENOENT; | 1028 | return -ENOENT; |
@@ -1044,7 +1044,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1044 | i2c->regs = devm_request_and_ioremap(&pdev->dev, res); | 1044 | i2c->regs = devm_request_and_ioremap(&pdev->dev, res); |
1045 | 1045 | ||
1046 | if (i2c->regs == NULL) { | 1046 | if (i2c->regs == NULL) { |
1047 | dev_err(&pdev->dev, "cannot map IO\n"); | 1047 | dev_err(&pdev->dev, "cannot request and map IO\n"); |
1048 | ret = -ENXIO; | 1048 | ret = -ENXIO; |
1049 | goto err_clk; | 1049 | goto err_clk; |
1050 | } | 1050 | } |
@@ -1084,8 +1084,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1084 | goto err_clk; | 1084 | goto err_clk; |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | ret = request_irq(i2c->irq, s3c24xx_i2c_irq, 0, | 1087 | ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0, |
1088 | dev_name(&pdev->dev), i2c); | 1088 | dev_name(&pdev->dev), i2c); |
1089 | 1089 | ||
1090 | if (ret != 0) { | 1090 | if (ret != 0) { |
1091 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); | 1091 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); |
@@ -1095,7 +1095,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1095 | ret = s3c24xx_i2c_register_cpufreq(i2c); | 1095 | ret = s3c24xx_i2c_register_cpufreq(i2c); |
1096 | if (ret < 0) { | 1096 | if (ret < 0) { |
1097 | dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); | 1097 | dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); |
1098 | goto err_irq; | 1098 | goto err_clk; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | /* Note, previous versions of the driver used i2c_add_adapter() | 1101 | /* Note, previous versions of the driver used i2c_add_adapter() |
@@ -1126,12 +1126,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1126 | err_cpufreq: | 1126 | err_cpufreq: |
1127 | s3c24xx_i2c_deregister_cpufreq(i2c); | 1127 | s3c24xx_i2c_deregister_cpufreq(i2c); |
1128 | 1128 | ||
1129 | err_irq: | ||
1130 | free_irq(i2c->irq, i2c); | ||
1131 | |||
1132 | err_clk: | 1129 | err_clk: |
1133 | clk_disable_unprepare(i2c->clk); | 1130 | clk_disable_unprepare(i2c->clk); |
1134 | clk_put(i2c->clk); | ||
1135 | return ret; | 1131 | return ret; |
1136 | } | 1132 | } |
1137 | 1133 | ||
@@ -1150,10 +1146,8 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) | |||
1150 | s3c24xx_i2c_deregister_cpufreq(i2c); | 1146 | s3c24xx_i2c_deregister_cpufreq(i2c); |
1151 | 1147 | ||
1152 | i2c_del_adapter(&i2c->adap); | 1148 | i2c_del_adapter(&i2c->adap); |
1153 | free_irq(i2c->irq, i2c); | ||
1154 | 1149 | ||
1155 | clk_disable_unprepare(i2c->clk); | 1150 | clk_disable_unprepare(i2c->clk); |
1156 | clk_put(i2c->clk); | ||
1157 | 1151 | ||
1158 | if (pdev->dev.of_node && IS_ERR(i2c->pctrl)) | 1152 | if (pdev->dev.of_node && IS_ERR(i2c->pctrl)) |
1159 | s3c24xx_i2c_dt_gpio_free(i2c); | 1153 | s3c24xx_i2c_dt_gpio_free(i2c); |