Skip to content

Commit

Permalink
watchdog: Convert wm831x driver to devm_kzalloc()
Browse files Browse the repository at this point in the history
Saves a small amount of code and systematically eliminates leaks.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  • Loading branch information
Mark Brown authored and Wim Van Sebroeck committed Jan 6, 2012
1 parent ff0b3cd commit 7b9bb6d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/watchdog/wm831x_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ static int __devinit wm831x_wdt_probe(struct platform_device *pdev)
if (reg & WM831X_WDOG_DEBUG)
dev_warn(wm831x->dev, "Watchdog is paused\n");

driver_data = kzalloc(sizeof(*driver_data), GFP_KERNEL);
driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data),
GFP_KERNEL);
if (!driver_data) {
dev_err(wm831x->dev, "Unable to alloacate watchdog device\n");
ret = -ENOMEM;
Expand Down Expand Up @@ -250,7 +251,7 @@ static int __devinit wm831x_wdt_probe(struct platform_device *pdev)
dev_err(wm831x->dev,
"Failed to request update GPIO: %d\n",
ret);
goto err_alloc;
goto err;
}

ret = gpio_direction_output(pdata->update_gpio, 0);
Expand Down Expand Up @@ -292,8 +293,6 @@ static int __devinit wm831x_wdt_probe(struct platform_device *pdev)
err_gpio:
if (driver_data->update_gpio)
gpio_free(driver_data->update_gpio);
err_alloc:
kfree(driver_data);
err:
return ret;
}
Expand Down

0 comments on commit 7b9bb6d

Please sign in to comment.