aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pps
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2013-02-27 20:05:44 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:23 -0500
commit507063b2a435b24951bce8e1f67ab65cda490f1b (patch)
treed166bc08e67dd39a2c360de5558ae0499a2ac6a2 /drivers/pps
parent11cd3db01bd8cc16aa82347582ef982cddc786e3 (diff)
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: Julia Lawall <Julia.Lawall@lip6.fr> Cc: Rodolfo Giometti <giometti@enneenne.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pps')
-rw-r--r--drivers/pps/clients/pps-gpio.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 2bf0c1b608dd..d3db26e46489 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -128,7 +128,8 @@ static int pps_gpio_probe(struct platform_device *pdev)
128 } 128 }
129 129
130 /* allocate space for device info */ 130 /* allocate space for device info */
131 data = kzalloc(sizeof(struct pps_gpio_device_data), GFP_KERNEL); 131 data = devm_kzalloc(&pdev->dev, sizeof(struct pps_gpio_device_data),
132 GFP_KERNEL);
132 if (data == NULL) { 133 if (data == NULL) {
133 err = -ENOMEM; 134 err = -ENOMEM;
134 goto return_error; 135 goto return_error;
@@ -150,7 +151,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
150 pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR; 151 pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR;
151 data->pps = pps_register_source(&data->info, pps_default_params); 152 data->pps = pps_register_source(&data->info, pps_default_params);
152 if (data->pps == NULL) { 153 if (data->pps == NULL) {
153 kfree(data);
154 pr_err("failed to register IRQ %d as PPS source\n", irq); 154 pr_err("failed to register IRQ %d as PPS source\n", irq);
155 err = -EINVAL; 155 err = -EINVAL;
156 goto return_error; 156 goto return_error;
@@ -164,7 +164,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
164 get_irqf_trigger_flags(pdata), data->info.name, data); 164 get_irqf_trigger_flags(pdata), data->info.name, data);
165 if (ret) { 165 if (ret) {
166 pps_unregister_source(data->pps); 166 pps_unregister_source(data->pps);
167 kfree(data);
168 pr_err("failed to acquire IRQ %d\n", irq); 167 pr_err("failed to acquire IRQ %d\n", irq);
169 err = -EINVAL; 168 err = -EINVAL;
170 goto return_error; 169 goto return_error;
@@ -190,7 +189,6 @@ static int pps_gpio_remove(struct platform_device *pdev)
190 gpio_free(pdata->gpio_pin); 189 gpio_free(pdata->gpio_pin);
191 pps_unregister_source(data->pps); 190 pps_unregister_source(data->pps);
192 pr_info("removed IRQ %d as PPS source\n", data->irq); 191 pr_info("removed IRQ %d as PPS source\n", data->irq);
193 kfree(data);
194 return 0; 192 return 0;
195} 193}
196 194