Patchwork [V2,04/13] i2c: isch: Use devm_request_region()

login
register
mail settings
Submitter Jingoo Han
Date Dec. 18, 2013, 1:48 a.m.
Message ID <007501cefb93$32ca0df0$985e29d0$%han@samsung.com>
Download mbox | patch
Permalink /patch/302610/
State Accepted
Headers show

Comments

Jingoo Han - Dec. 18, 2013, 1:48 a.m.
Use devm_request_region() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
Changes since V1:
- Remove unnecessary 'res' variable from smbus_sch_remove().

 drivers/i2c/busses/i2c-isch.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
Jean Delvare - Dec. 18, 2013, 7:46 a.m.
On Wed, 18 Dec 2013 10:48:07 +0900, Jingoo Han wrote:
> Use devm_request_region() to make cleanup paths simpler.
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> ---
> Changes since V1:
> - Remove unnecessary 'res' variable from smbus_sch_remove().
> 
>  drivers/i2c/busses/i2c-isch.c |    7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c
> index 8c38aaa..af21304 100644
> --- a/drivers/i2c/busses/i2c-isch.c
> +++ b/drivers/i2c/busses/i2c-isch.c
> @@ -275,7 +275,8 @@ static int smbus_sch_probe(struct platform_device *dev)
>  	if (!res)
>  		return -EBUSY;
>  
> -	if (!request_region(res->start, resource_size(res), dev->name)) {
> +	if (!devm_request_region(&dev->dev, res->start, resource_size(res),
> +				 dev->name)) {
>  		dev_err(&dev->dev, "SMBus region 0x%x already in use!\n",
>  			sch_smba);
>  		return -EBUSY;
> @@ -294,7 +295,6 @@ static int smbus_sch_probe(struct platform_device *dev)
>  	retval = i2c_add_adapter(&sch_adapter);
>  	if (retval) {
>  		dev_err(&dev->dev, "Couldn't register adapter!\n");
> -		release_region(res->start, resource_size(res));
>  		sch_smba = 0;
>  	}
>  
> @@ -303,11 +303,8 @@ static int smbus_sch_probe(struct platform_device *dev)
>  
>  static int smbus_sch_remove(struct platform_device *pdev)
>  {
> -	struct resource *res;
>  	if (sch_smba) {
>  		i2c_del_adapter(&sch_adapter);
> -		res = platform_get_resource(pdev, IORESOURCE_IO, 0);
> -		release_region(res->start, resource_size(res));
>  		sch_smba = 0;
>  	}
>  

Reviewed-by: Jean Delvare <khali@linux-fr.org>
Wolfram Sang - Jan. 4, 2014, 9:23 p.m.
On Wed, Dec 18, 2013 at 10:48:07AM +0900, Jingoo Han wrote:
> Use devm_request_region() to make cleanup paths simpler.
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>

OK, this got reviewed. Applied to for-next, thanks!

Patch

diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c
index 8c38aaa..af21304 100644
--- a/drivers/i2c/busses/i2c-isch.c
+++ b/drivers/i2c/busses/i2c-isch.c
@@ -275,7 +275,8 @@  static int smbus_sch_probe(struct platform_device *dev)
 	if (!res)
 		return -EBUSY;
 
-	if (!request_region(res->start, resource_size(res), dev->name)) {
+	if (!devm_request_region(&dev->dev, res->start, resource_size(res),
+				 dev->name)) {
 		dev_err(&dev->dev, "SMBus region 0x%x already in use!\n",
 			sch_smba);
 		return -EBUSY;
@@ -294,7 +295,6 @@  static int smbus_sch_probe(struct platform_device *dev)
 	retval = i2c_add_adapter(&sch_adapter);
 	if (retval) {
 		dev_err(&dev->dev, "Couldn't register adapter!\n");
-		release_region(res->start, resource_size(res));
 		sch_smba = 0;
 	}
 
@@ -303,11 +303,8 @@  static int smbus_sch_probe(struct platform_device *dev)
 
 static int smbus_sch_remove(struct platform_device *pdev)
 {
-	struct resource *res;
 	if (sch_smba) {
 		i2c_del_adapter(&sch_adapter);
-		res = platform_get_resource(pdev, IORESOURCE_IO, 0);
-		release_region(res->start, resource_size(res));
 		sch_smba = 0;
 	}