Patchwork [11/13] i2c: versatile: Use devm_*() functions

login
register
mail settings
Submitter Jingoo Han
Date Dec. 17, 2013, 7 a.m.
Message ID <002f01cefaf5$b943e890$2bcbb9b0$%han@samsung.com>
Download mbox | patch
Permalink /patch/302013/
State Deferred
Headers show

Comments

Jingoo Han - Dec. 17, 2013, 7 a.m.
Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/i2c/busses/i2c-versatile.c |   33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)

Patch

diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
index 6bb3a89..6bcd477 100644
--- a/drivers/i2c/busses/i2c-versatile.c
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -71,27 +71,16 @@  static int i2c_versatile_probe(struct platform_device *dev)
 	int ret;
 
 	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	if (!r) {
-		ret = -EINVAL;
-		goto err_out;
-	}
+	if (!r)
+		return -EINVAL;
 
-	if (!request_mem_region(r->start, resource_size(r), "versatile-i2c")) {
-		ret = -EBUSY;
-		goto err_out;
-	}
+	i2c = devm_kzalloc(&dev->dev, sizeof(struct i2c_versatile), GFP_KERNEL);
+	if (!i2c)
+		return -ENOMEM;
 
-	i2c = kzalloc(sizeof(struct i2c_versatile), GFP_KERNEL);
-	if (!i2c) {
-		ret = -ENOMEM;
-		goto err_release;
-	}
-
-	i2c->base = ioremap(r->start, resource_size(r));
-	if (!i2c->base) {
-		ret = -ENOMEM;
-		goto err_free;
-	}
+	i2c->base = devm_ioremap_resource(&dev->dev, r);
+	if (IS_ERR(i2c->base))
+		return PTR_ERR(i2c->base);
 
 	writel(SCL | SDA, i2c->base + I2C_CONTROLS);
 
@@ -110,12 +99,6 @@  static int i2c_versatile_probe(struct platform_device *dev)
 		return 0;
 	}
 
-	iounmap(i2c->base);
- err_free:
-	kfree(i2c);
- err_release:
-	release_mem_region(r->start, resource_size(r));
- err_out:
 	return ret;
 }