Commit 0a5c6a22 authored by Frans Klaver's avatar Frans Klaver Committed by Sebastian Reichel

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: default avatarFrans Klaver <frans.klaver@xsens.com>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 0160817d
...@@ -292,7 +292,8 @@ static int ltc2952_poweroff_probe(struct platform_device *pdev) ...@@ -292,7 +292,8 @@ static int ltc2952_poweroff_probe(struct platform_device *pdev)
return -EBUSY; return -EBUSY;
} }
ltc2952_data = kzalloc(sizeof(*ltc2952_data), GFP_KERNEL); ltc2952_data = devm_kzalloc(&pdev->dev, sizeof(*ltc2952_data),
GFP_KERNEL);
if (!ltc2952_data) if (!ltc2952_data)
return -ENOMEM; return -ENOMEM;
...@@ -300,17 +301,13 @@ static int ltc2952_poweroff_probe(struct platform_device *pdev) ...@@ -300,17 +301,13 @@ static int ltc2952_poweroff_probe(struct platform_device *pdev)
ret = ltc2952_poweroff_init(pdev); ret = ltc2952_poweroff_init(pdev);
if (ret) if (ret)
goto err; return ret;
pm_power_off = &ltc2952_poweroff_kill; pm_power_off = &ltc2952_poweroff_kill;
dev_info(&pdev->dev, "probe successful\n"); dev_info(&pdev->dev, "probe successful\n");
return 0; return 0;
err:
kfree(ltc2952_data);
return ret;
} }
static int ltc2952_poweroff_remove(struct platform_device *pdev) static int ltc2952_poweroff_remove(struct platform_device *pdev)
...@@ -324,8 +321,6 @@ 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++) for (i = 0; i < ARRAY_SIZE(ltc2952_data->gpio); i++)
gpiod_put(ltc2952_data->gpio[i]); gpiod_put(ltc2952_data->gpio[i]);
kfree(ltc2952_data);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment