linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: at32watchdog: use devm_kzalloc
@ 2012-11-03  7:10 Devendra Naga
  0 siblings, 0 replies; only message in thread
From: Devendra Naga @ 2012-11-03  7:10 UTC (permalink / raw)
  To: Hans-Christian Egtvedt, Wim Van sebroeck, linux-watchdog; +Cc: Devendra Naga

use the devm_kzalloc and no need of error path free's

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
 drivers/watchdog/at32ap700x_wdt.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c
index 2896430..dc2e312 100644
--- a/drivers/watchdog/at32ap700x_wdt.c
+++ b/drivers/watchdog/at32ap700x_wdt.c
@@ -321,7 +321,7 @@ 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;
@@ -329,9 +329,8 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
 
 	wdt->regs = ioremap(regs->start, resource_size(regs));
 	if (!wdt->regs) {
-		ret = -ENOMEM;
 		dev_dbg(&pdev->dev, "could not map I/O memory\n");
-		goto err_free;
+		return -ENOMEM;
 	}
 
 	spin_lock_init(&wdt->io_lock);
@@ -377,9 +376,6 @@ err_register:
 	platform_set_drvdata(pdev, NULL);
 err_iounmap:
 	iounmap(wdt->regs);
-err_free:
-	kfree(wdt);
-	wdt = NULL;
 	return ret;
 }
 
@@ -392,8 +388,6 @@ static int __exit at32_wdt_remove(struct platform_device *pdev)
 
 		misc_deregister(&wdt->miscdev);
 		iounmap(wdt->regs);
-		kfree(wdt);
-		wdt = NULL;
 		platform_set_drvdata(pdev, NULL);
 	}
 	return 0;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-03  7:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-03  7:10 [PATCH] watchdog: at32watchdog: use devm_kzalloc Devendra Naga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).