public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND 1/7] watchdog: at32ap700x_wdt: use devm_*() functions
@ 2013-04-29  9:34 Jingoo Han
  2013-04-29 17:52 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Jingoo Han @ 2013-04-29  9:34 UTC (permalink / raw)
  To: 'Andrew Morton'
  Cc: linux-kernel, 'Wim Van Sebroeck', linux-watchdog,
	'Jingoo Han'

Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/watchdog/at32ap700x_wdt.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c
index 7a715e3..c4cb552 100644
--- a/drivers/watchdog/at32ap700x_wdt.c
+++ b/drivers/watchdog/at32ap700x_wdt.c
@@ -321,13 +321,14 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	wdt = kzalloc(sizeof(struct wdt_at32ap700x), GFP_KERNEL);
+	wdt = devm_kzalloc(&pdev->dev, sizeof(struct wdt_at32ap700x),
+			GFP_KERNEL);
 	if (!wdt) {
 		dev_dbg(&pdev->dev, "no memory for wdt structure\n");
 		return -ENOMEM;
 	}
 
-	wdt->regs = ioremap(regs->start, resource_size(regs));
+	wdt->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
 	if (!wdt->regs) {
 		ret = -ENOMEM;
 		dev_dbg(&pdev->dev, "could not map I/O memory\n");
@@ -342,7 +343,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
 		dev_info(&pdev->dev, "CPU must be reset with external "
 				"reset or POR due to silicon errata.\n");
 		ret = -EIO;
-		goto err_iounmap;
+		goto err_free;
 	} else {
 		wdt->users = 0;
 	}
@@ -375,10 +376,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
 
 err_register:
 	platform_set_drvdata(pdev, NULL);
-err_iounmap:
-	iounmap(wdt->regs);
 err_free:
-	kfree(wdt);
 	wdt = NULL;
 	return ret;
 }
@@ -391,8 +389,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev)
 			at32_wdt_stop();
 
 		misc_deregister(&wdt->miscdev);
-		iounmap(wdt->regs);
-		kfree(wdt);
 		wdt = NULL;
 		platform_set_drvdata(pdev, NULL);
 	}
-- 
1.7.2.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND 1/7] watchdog: at32ap700x_wdt: use devm_*() functions
  2013-04-29  9:34 [PATCH RESEND 1/7] watchdog: at32ap700x_wdt: use devm_*() functions Jingoo Han
@ 2013-04-29 17:52 ` Guenter Roeck
  0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2013-04-29 17:52 UTC (permalink / raw)
  To: Jingoo Han
  Cc: 'Andrew Morton', linux-kernel, 'Wim Van Sebroeck',
	linux-watchdog

On Mon, Apr 29, 2013 at 06:34:31PM +0900, Jingoo Han wrote:
> Use devm_*() functions to make cleanup paths simpler.
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> ---
>  drivers/watchdog/at32ap700x_wdt.c |   12 ++++--------
>  1 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c
> index 7a715e3..c4cb552 100644
> --- a/drivers/watchdog/at32ap700x_wdt.c
> +++ b/drivers/watchdog/at32ap700x_wdt.c
> @@ -321,13 +321,14 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
>  		return -ENXIO;
>  	}
>  
> -	wdt = kzalloc(sizeof(struct wdt_at32ap700x), GFP_KERNEL);
> +	wdt = devm_kzalloc(&pdev->dev, sizeof(struct wdt_at32ap700x),
> +			GFP_KERNEL);
>  	if (!wdt) {
>  		dev_dbg(&pdev->dev, "no memory for wdt structure\n");
>  		return -ENOMEM;
>  	}
>  
> -	wdt->regs = ioremap(regs->start, resource_size(regs));
> +	wdt->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
>  	if (!wdt->regs) {
>  		ret = -ENOMEM;
>  		dev_dbg(&pdev->dev, "could not map I/O memory\n");
> @@ -342,7 +343,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
>  		dev_info(&pdev->dev, "CPU must be reset with external "
>  				"reset or POR due to silicon errata.\n");
>  		ret = -EIO;
> -		goto err_iounmap;
> +		goto err_free;
>  	} else {
>  		wdt->users = 0;
>  	}
> @@ -375,10 +376,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
>  
>  err_register:
>  	platform_set_drvdata(pdev, NULL);
> -err_iounmap:
> -	iounmap(wdt->regs);
>  err_free:
> -	kfree(wdt);
>  	wdt = NULL;
>  	return ret;
>  }
> @@ -391,8 +389,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev)
>  			at32_wdt_stop();
>  
>  		misc_deregister(&wdt->miscdev);
> -		iounmap(wdt->regs);
> -		kfree(wdt);
>  		wdt = NULL;
>  		platform_set_drvdata(pdev, NULL);
>  	}

err_free isn't really appropriate anymore as label,
and platform_set_drvdata(pdev, NULL) as well as the associated complexity
in at32_wdt_remove is not really needed, but especially the latter should
really be addressed in another patch, so

Acked-by: Guenter Roeck <linux@roeck-us.net>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH RESEND 1/7] watchdog: at32ap700x_wdt: use devm_*() functions
@ 2013-05-02  5:49 Jingoo Han
  0 siblings, 0 replies; 3+ messages in thread
From: Jingoo Han @ 2013-05-02  5:49 UTC (permalink / raw)
  To: 'Andrew Morton'
  Cc: linux-kernel, 'Wim Van Sebroeck', linux-watchdog,
	'Guenter Roeck', 'Jingoo Han'

Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/watchdog/at32ap700x_wdt.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c
index 7a715e3..c4cb552 100644
--- a/drivers/watchdog/at32ap700x_wdt.c
+++ b/drivers/watchdog/at32ap700x_wdt.c
@@ -321,13 +321,14 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	wdt = kzalloc(sizeof(struct wdt_at32ap700x), GFP_KERNEL);
+	wdt = devm_kzalloc(&pdev->dev, sizeof(struct wdt_at32ap700x),
+			GFP_KERNEL);
 	if (!wdt) {
 		dev_dbg(&pdev->dev, "no memory for wdt structure\n");
 		return -ENOMEM;
 	}
 
-	wdt->regs = ioremap(regs->start, resource_size(regs));
+	wdt->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
 	if (!wdt->regs) {
 		ret = -ENOMEM;
 		dev_dbg(&pdev->dev, "could not map I/O memory\n");
@@ -342,7 +343,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
 		dev_info(&pdev->dev, "CPU must be reset with external "
 				"reset or POR due to silicon errata.\n");
 		ret = -EIO;
-		goto err_iounmap;
+		goto err_free;
 	} else {
 		wdt->users = 0;
 	}
@@ -375,10 +376,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
 
 err_register:
 	platform_set_drvdata(pdev, NULL);
-err_iounmap:
-	iounmap(wdt->regs);
 err_free:
-	kfree(wdt);
 	wdt = NULL;
 	return ret;
 }
@@ -391,8 +389,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev)
 			at32_wdt_stop();
 
 		misc_deregister(&wdt->miscdev);
-		iounmap(wdt->regs);
-		kfree(wdt);
 		wdt = NULL;
 		platform_set_drvdata(pdev, NULL);
 	}
-- 
1.7.2.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-02  5:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-29  9:34 [PATCH RESEND 1/7] watchdog: at32ap700x_wdt: use devm_*() functions Jingoo Han
2013-04-29 17:52 ` Guenter Roeck
  -- strict thread matches above, loose matches on Subject: below --
2013-05-02  5:49 Jingoo Han

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox