i2c: davinci: update to devm_* API
diff mbox

Message ID 1360052699-1985-1-git-send-email-manishv.b@ti.com
State Superseded
Headers show

Commit Message

Vishwanathrao Badarkhe, Manish Feb. 5, 2013, 8:24 a.m. UTC
Update the code to use devm_* API so that driver
core will manage resources.

Signed-off-by: Vishwanathrao Badarkhe, Manish <manishv.b@ti.com>
---
:100644 100644 6a0a553... f3dfffb... M	drivers/i2c/busses/i2c-davinci.c
 drivers/i2c/busses/i2c-davinci.c |   41 +++++++++++--------------------------
 1 files changed, 12 insertions(+), 29 deletions(-)

Comments

Sekhar Nori Feb. 5, 2013, 11:47 a.m. UTC | #1
On 2/5/2013 1:54 PM, Vishwanathrao Badarkhe, Manish wrote:
> Update the code to use devm_* API so that driver
> core will manage resources.
> 
> Signed-off-by: Vishwanathrao Badarkhe, Manish <manishv.b@ti.com>

You can use devm_clk_get() as well. We should also move to runtime PM
but that can be a different patch.

Thanks,
Sekhar

> ---
> :100644 100644 6a0a553... f3dfffb... M	drivers/i2c/busses/i2c-davinci.c
>  drivers/i2c/busses/i2c-davinci.c |   41 +++++++++++--------------------------
>  1 files changed, 12 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
> index 6a0a553..f3dfffb 100644
> --- a/drivers/i2c/busses/i2c-davinci.c
> +++ b/drivers/i2c/busses/i2c-davinci.c
> @@ -643,7 +643,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
>  {
>  	struct davinci_i2c_dev *dev;
>  	struct i2c_adapter *adap;
> -	struct resource *mem, *irq, *ioarea;
> +	struct resource *mem, *irq;
>  	int r;
>  
>  	/* NOTE: driver uses the static register mapping */
> @@ -659,17 +659,11 @@ static int davinci_i2c_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> -	ioarea = request_mem_region(mem->start, resource_size(mem),
> -				    pdev->name);
> -	if (!ioarea) {
> -		dev_err(&pdev->dev, "I2C region already claimed\n");
> -		return -EBUSY;
> -	}
> -
> -	dev = kzalloc(sizeof(struct davinci_i2c_dev), GFP_KERNEL);
> +	dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev),
> +			GFP_KERNEL);
>  	if (!dev) {
> -		r = -ENOMEM;
> -		goto err_release_region;
> +		dev_err(&pdev->dev, "Memory allocation failed\n");
> +		return -ENOMEM;
>  	}
>  
>  	init_completion(&dev->cmd_complete);
> @@ -706,15 +700,17 @@ static int davinci_i2c_probe(struct platform_device *pdev)
>  	}
>  	clk_prepare_enable(dev->clk);
>  
> -	dev->base = ioremap(mem->start, resource_size(mem));
> +	dev->base = devm_request_and_ioremap(&pdev->dev, mem);
>  	if (!dev->base) {
>  		r = -EBUSY;
> -		goto err_mem_ioremap;
> +		dev_err(&pdev->dev, "I2C region already claimed\n");
> +		goto err_unuse_clocks;
>  	}
>  
>  	i2c_davinci_init(dev);
>  
> -	r = request_irq(dev->irq, i2c_davinci_isr, 0, pdev->name, dev);
> +	r = devm_request_irq(&pdev->dev, dev->irq, i2c_davinci_isr, 0,
> +			pdev->name, dev);
>  	if (r) {
>  		dev_err(&pdev->dev, "failure requesting irq %i\n", dev->irq);
>  		goto err_unuse_clocks;
> @@ -723,7 +719,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
>  	r = i2c_davinci_cpufreq_register(dev);
>  	if (r) {
>  		dev_err(&pdev->dev, "failed to register cpufreq\n");
> -		goto err_free_irq;
> +		goto err_unuse_clocks;
>  	}
>  
>  	adap = &dev->adapter;
> @@ -740,26 +736,19 @@ static int davinci_i2c_probe(struct platform_device *pdev)
>  	r = i2c_add_numbered_adapter(adap);
>  	if (r) {
>  		dev_err(&pdev->dev, "failure adding adapter\n");
> -		goto err_free_irq;
> +		goto err_unuse_clocks;
>  	}
>  	of_i2c_register_devices(adap);
>  
>  	return 0;
>  
> -err_free_irq:
> -	free_irq(dev->irq, dev);
>  err_unuse_clocks:
> -	iounmap(dev->base);
> -err_mem_ioremap:
>  	clk_disable_unprepare(dev->clk);
>  	clk_put(dev->clk);
>  	dev->clk = NULL;
>  err_free_mem:
>  	platform_set_drvdata(pdev, NULL);
>  	put_device(&pdev->dev);
> -	kfree(dev);
> -err_release_region:
> -	release_mem_region(mem->start, resource_size(mem));
>  
>  	return r;
>  }
> @@ -767,7 +756,6 @@ err_release_region:
>  static int davinci_i2c_remove(struct platform_device *pdev)
>  {
>  	struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
> -	struct resource *mem;
>  
>  	i2c_davinci_cpufreq_deregister(dev);
>  
> @@ -780,12 +768,7 @@ static int davinci_i2c_remove(struct platform_device *pdev)
>  	dev->clk = NULL;
>  
>  	davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0);
> -	free_irq(dev->irq, dev);
> -	iounmap(dev->base);
> -	kfree(dev);
>  
> -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	release_mem_region(mem->start, resource_size(mem));
>  	return 0;
>  }
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vishwanathrao Badarkhe, Manish Feb. 6, 2013, 3:53 a.m. UTC | #2
SGkgU2VraGFyDQoNCk9uIFR1ZSwgRmViIDA1LCAyMDEzIGF0IDE3OjE3OjI1LCBOb3JpLCBTZWto
YXIgd3JvdGU6DQo+IA0KPiANCj4gT24gMi81LzIwMTMgMTo1NCBQTSwgVmlzaHdhbmF0aHJhbyBC
YWRhcmtoZSwgTWFuaXNoIHdyb3RlOg0KPiA+IFVwZGF0ZSB0aGUgY29kZSB0byB1c2UgZGV2bV8q
IEFQSSBzbyB0aGF0IGRyaXZlciBjb3JlIHdpbGwgbWFuYWdlIA0KPiA+IHJlc291cmNlcy4NCj4g
PiANCj4gPiBTaWduZWQtb2ZmLWJ5OiBWaXNod2FuYXRocmFvIEJhZGFya2hlLCBNYW5pc2ggPG1h
bmlzaHYuYkB0aS5jb20+DQo+IA0KPiBZb3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AgLTc4MCwxMiArNzY4LDcgQEAgc3RhdGljIGludCBk
YXZpbmNpX2kyY19yZW1vdmUoc3RydWN0IHBsYXRmb3JtX2RldmljZSAqcGRldikNCj4gPiAgCWRl
di0+Y2xrID0gTlVMTDsNCj4gPiAgDQo+ID4gIAlkYXZpbmNpX2kyY193cml0ZV9yZWcoZGV2LCBE
QVZJTkNJX0kyQ19NRFJfUkVHLCAwKTsNCj4gPiAtCWZyZWVfaXJxKGRldi0+aXJxLCBkZXYpOw0K
PiA+IC0JaW91bm1hcChkZXYtPmJhc2UpOw0KPiA+IC0Ja2ZyZWUoZGV2KTsNCj4gPiAgDQo+ID4g
LQltZW0gPSBwbGF0Zm9ybV9nZXRfcmVzb3VyY2UocGRldiwgSU9SRVNPVVJDRV9NRU0sIDApOw0K
PiA+IC0JcmVsZWFzZV9tZW1fcmVnaW9uKG1lbS0+c3RhcnQsIHJlc291cmNlX3NpemUobWVtKSk7
DQo+ID4gIAlyZXR1cm4gMDsNCj4gPiAgfQ0KPiA+ICANCj4gPiANCj4gDQoNCg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 6a0a553..f3dfffb 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -643,7 +643,7 @@  static int davinci_i2c_probe(struct platform_device *pdev)
 {
 	struct davinci_i2c_dev *dev;
 	struct i2c_adapter *adap;
-	struct resource *mem, *irq, *ioarea;
+	struct resource *mem, *irq;
 	int r;
 
 	/* NOTE: driver uses the static register mapping */
@@ -659,17 +659,11 @@  static int davinci_i2c_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	ioarea = request_mem_region(mem->start, resource_size(mem),
-				    pdev->name);
-	if (!ioarea) {
-		dev_err(&pdev->dev, "I2C region already claimed\n");
-		return -EBUSY;
-	}
-
-	dev = kzalloc(sizeof(struct davinci_i2c_dev), GFP_KERNEL);
+	dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev),
+			GFP_KERNEL);
 	if (!dev) {
-		r = -ENOMEM;
-		goto err_release_region;
+		dev_err(&pdev->dev, "Memory allocation failed\n");
+		return -ENOMEM;
 	}
 
 	init_completion(&dev->cmd_complete);
@@ -706,15 +700,17 @@  static int davinci_i2c_probe(struct platform_device *pdev)
 	}
 	clk_prepare_enable(dev->clk);
 
-	dev->base = ioremap(mem->start, resource_size(mem));
+	dev->base = devm_request_and_ioremap(&pdev->dev, mem);
 	if (!dev->base) {
 		r = -EBUSY;
-		goto err_mem_ioremap;
+		dev_err(&pdev->dev, "I2C region already claimed\n");
+		goto err_unuse_clocks;
 	}
 
 	i2c_davinci_init(dev);
 
-	r = request_irq(dev->irq, i2c_davinci_isr, 0, pdev->name, dev);
+	r = devm_request_irq(&pdev->dev, dev->irq, i2c_davinci_isr, 0,
+			pdev->name, dev);
 	if (r) {
 		dev_err(&pdev->dev, "failure requesting irq %i\n", dev->irq);
 		goto err_unuse_clocks;
@@ -723,7 +719,7 @@  static int davinci_i2c_probe(struct platform_device *pdev)
 	r = i2c_davinci_cpufreq_register(dev);
 	if (r) {
 		dev_err(&pdev->dev, "failed to register cpufreq\n");
-		goto err_free_irq;
+		goto err_unuse_clocks;
 	}
 
 	adap = &dev->adapter;
@@ -740,26 +736,19 @@  static int davinci_i2c_probe(struct platform_device *pdev)
 	r = i2c_add_numbered_adapter(adap);
 	if (r) {
 		dev_err(&pdev->dev, "failure adding adapter\n");
-		goto err_free_irq;
+		goto err_unuse_clocks;
 	}
 	of_i2c_register_devices(adap);
 
 	return 0;
 
-err_free_irq:
-	free_irq(dev->irq, dev);
 err_unuse_clocks:
-	iounmap(dev->base);
-err_mem_ioremap:
 	clk_disable_unprepare(dev->clk);
 	clk_put(dev->clk);
 	dev->clk = NULL;
 err_free_mem:
 	platform_set_drvdata(pdev, NULL);
 	put_device(&pdev->dev);
-	kfree(dev);
-err_release_region:
-	release_mem_region(mem->start, resource_size(mem));
 
 	return r;
 }
@@ -767,7 +756,6 @@  err_release_region:
 static int davinci_i2c_remove(struct platform_device *pdev)
 {
 	struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
-	struct resource *mem;
 
 	i2c_davinci_cpufreq_deregister(dev);
 
@@ -780,12 +768,7 @@  static int davinci_i2c_remove(struct platform_device *pdev)
 	dev->clk = NULL;
 
 	davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0);
-	free_irq(dev->irq, dev);
-	iounmap(dev->base);
-	kfree(dev);
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(mem->start, resource_size(mem));
 	return 0;
 }