[RESEND PATCH v3 2/6] watchdog: omap_wdt: convert kzalloc() to devm_kzalloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use devm_kzalloc() to simplify the code.

Signed-off-by: Aaro Koskinen <aaro.koskinen@xxxxxx>
---
 drivers/watchdog/omap_wdt.c |   23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index d28ad5e..d6722db 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -208,24 +208,20 @@ static int __devinit omap_wdt_probe(struct platform_device *pdev)
 	struct omap_wdt_dev *wdev;
 	int ret;
 
-	omap_wdt = kzalloc(sizeof(*omap_wdt), GFP_KERNEL);
+	omap_wdt = devm_kzalloc(&pdev->dev, sizeof(*omap_wdt), GFP_KERNEL);
 	if (!omap_wdt)
 		return -ENOMEM;
 
 	/* reserve static register mappings */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		ret = -ENOENT;
-		goto err_get_resource;
-	}
+	if (!res)
+		return -ENOENT;
 
 	mem = request_mem_region(res->start, resource_size(res), pdev->name);
-	if (!mem) {
-		ret = -EBUSY;
-		goto err_busy;
-	}
+	if (!mem)
+		return -EBUSY;
 
-	wdev = kzalloc(sizeof(struct omap_wdt_dev), GFP_KERNEL);
+	wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
 	if (!wdev) {
 		ret = -ENOMEM;
 		goto err_kzalloc;
@@ -292,14 +288,10 @@ err_misc:
 
 err_ioremap:
 	wdev->base = NULL;
-	kfree(wdev);
 
 err_kzalloc:
 	release_mem_region(res->start, resource_size(res));
 
-err_busy:
-err_get_resource:
-	kfree(omap_wdt);
 	return ret;
 }
 
@@ -329,9 +321,6 @@ static int __devexit omap_wdt_remove(struct platform_device *pdev)
 
 	iounmap(wdev->base);
 
-	kfree(wdev);
-	kfree(wdog);
-
 	return 0;
 }
 
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux