diff options
author | Frans Klaver <frans.klaver@xsens.com> | 2015-01-14 09:15:34 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-01-20 13:58:27 +0100 |
commit | 0a5c6a2276fe06a3ebb6a9ed26c0b8007074958e (patch) | |
tree | 7864e40f3c10ef4012c03229b767637831c65a4d /drivers/power | |
parent | 0160817d10a97900b9ee08a8b8b2f5a148e2be0f (diff) | |
download | talos-obmc-linux-0a5c6a2276fe06a3ebb6a9ed26c0b8007074958e.tar.gz talos-obmc-linux-0a5c6a2276fe06a3ebb6a9ed26c0b8007074958e.zip |
power: reset: ltc2952: prefer devm_kzalloc over kzalloc
Make use of the fact that the allocated resources can be automatically
deallocated. This reduces cleanup code and chance of leaks.
Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/reset/ltc2952-poweroff.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c index 34f38a3dc3ff..6487b991ed45 100644 --- a/drivers/power/reset/ltc2952-poweroff.c +++ b/drivers/power/reset/ltc2952-poweroff.c @@ -292,7 +292,8 @@ static int ltc2952_poweroff_probe(struct platform_device *pdev) return -EBUSY; } - ltc2952_data = kzalloc(sizeof(*ltc2952_data), GFP_KERNEL); + ltc2952_data = devm_kzalloc(&pdev->dev, sizeof(*ltc2952_data), + GFP_KERNEL); if (!ltc2952_data) return -ENOMEM; @@ -300,17 +301,13 @@ static int ltc2952_poweroff_probe(struct platform_device *pdev) ret = ltc2952_poweroff_init(pdev); if (ret) - goto err; + return ret; pm_power_off = <c2952_poweroff_kill; dev_info(&pdev->dev, "probe successful\n"); return 0; - -err: - kfree(ltc2952_data); - return ret; } static int ltc2952_poweroff_remove(struct platform_device *pdev) @@ -324,8 +321,6 @@ static int ltc2952_poweroff_remove(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(ltc2952_data->gpio); i++) gpiod_put(ltc2952_data->gpio[i]); - - kfree(ltc2952_data); } return 0; |