Commit 507063b2 authored by Julia Lawall's avatar Julia Lawall Committed by Linus Torvalds

drivers/pps/clients/pps-gpio.c: use devm_kzalloc

devm_kzalloc allocates memory that is released when a driver detaches.
This patch uses devm_kzalloc for data that is allocated in the probe
function of a platform device and is only freed in the remove function.
Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Cc: Rodolfo Giometti <giometti@enneenne.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 11cd3db0
...@@ -128,7 +128,8 @@ static int pps_gpio_probe(struct platform_device *pdev) ...@@ -128,7 +128,8 @@ static int pps_gpio_probe(struct platform_device *pdev)
} }
/* allocate space for device info */ /* allocate space for device info */
data = kzalloc(sizeof(struct pps_gpio_device_data), GFP_KERNEL); data = devm_kzalloc(&pdev->dev, sizeof(struct pps_gpio_device_data),
GFP_KERNEL);
if (data == NULL) { if (data == NULL) {
err = -ENOMEM; err = -ENOMEM;
goto return_error; goto return_error;
...@@ -150,7 +151,6 @@ static int pps_gpio_probe(struct platform_device *pdev) ...@@ -150,7 +151,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR; pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR;
data->pps = pps_register_source(&data->info, pps_default_params); data->pps = pps_register_source(&data->info, pps_default_params);
if (data->pps == NULL) { if (data->pps == NULL) {
kfree(data);
pr_err("failed to register IRQ %d as PPS source\n", irq); pr_err("failed to register IRQ %d as PPS source\n", irq);
err = -EINVAL; err = -EINVAL;
goto return_error; goto return_error;
...@@ -164,7 +164,6 @@ static int pps_gpio_probe(struct platform_device *pdev) ...@@ -164,7 +164,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
get_irqf_trigger_flags(pdata), data->info.name, data); get_irqf_trigger_flags(pdata), data->info.name, data);
if (ret) { if (ret) {
pps_unregister_source(data->pps); pps_unregister_source(data->pps);
kfree(data);
pr_err("failed to acquire IRQ %d\n", irq); pr_err("failed to acquire IRQ %d\n", irq);
err = -EINVAL; err = -EINVAL;
goto return_error; goto return_error;
...@@ -190,7 +189,6 @@ static int pps_gpio_remove(struct platform_device *pdev) ...@@ -190,7 +189,6 @@ static int pps_gpio_remove(struct platform_device *pdev)
gpio_free(pdata->gpio_pin); gpio_free(pdata->gpio_pin);
pps_unregister_source(data->pps); pps_unregister_source(data->pps);
pr_info("removed IRQ %d as PPS source\n", data->irq); pr_info("removed IRQ %d as PPS source\n", data->irq);
kfree(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