Commit 2a651822 authored by Jan Luebbe's avatar Jan Luebbe Committed by Linus Torvalds

drivers/pps/clients/pps-gpio.c: convert to devm_* helpers

Signed-off-by: default avatarJan Luebbe <jlu@pengutronix.de>
Acked-by: default avatarRodolfo 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 c32df4e1
...@@ -74,7 +74,7 @@ static int pps_gpio_setup(struct platform_device *pdev) ...@@ -74,7 +74,7 @@ static int pps_gpio_setup(struct platform_device *pdev)
int ret; int ret;
const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data; const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
ret = gpio_request(pdata->gpio_pin, pdata->gpio_label); ret = devm_gpio_request(&pdev->dev, pdata->gpio_pin, pdata->gpio_label);
if (ret) { if (ret) {
pr_warning("failed to request GPIO %u\n", pdata->gpio_pin); pr_warning("failed to request GPIO %u\n", pdata->gpio_pin);
return -EINVAL; return -EINVAL;
...@@ -83,7 +83,6 @@ static int pps_gpio_setup(struct platform_device *pdev) ...@@ -83,7 +83,6 @@ static int pps_gpio_setup(struct platform_device *pdev)
ret = gpio_direction_input(pdata->gpio_pin); ret = gpio_direction_input(pdata->gpio_pin);
if (ret) { if (ret) {
pr_warning("failed to set pin direction\n"); pr_warning("failed to set pin direction\n");
gpio_free(pdata->gpio_pin);
return -EINVAL; return -EINVAL;
} }
...@@ -109,7 +108,6 @@ static int pps_gpio_probe(struct platform_device *pdev) ...@@ -109,7 +108,6 @@ static int pps_gpio_probe(struct platform_device *pdev)
struct pps_gpio_device_data *data; struct pps_gpio_device_data *data;
int irq; int irq;
int ret; int ret;
int err;
int pps_default_params; int pps_default_params;
const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data; const struct pps_gpio_platform_data *pdata = pdev->dev.platform_data;
...@@ -123,17 +121,14 @@ static int pps_gpio_probe(struct platform_device *pdev) ...@@ -123,17 +121,14 @@ static int pps_gpio_probe(struct platform_device *pdev)
irq = gpio_to_irq(pdata->gpio_pin); irq = gpio_to_irq(pdata->gpio_pin);
if (irq < 0) { if (irq < 0) {
pr_err("failed to map GPIO to IRQ: %d\n", irq); pr_err("failed to map GPIO to IRQ: %d\n", irq);
err = -EINVAL; return -EINVAL;
goto return_error;
} }
/* allocate space for device info */ /* allocate space for device info */
data = devm_kzalloc(&pdev->dev, sizeof(struct pps_gpio_device_data), data = devm_kzalloc(&pdev->dev, sizeof(struct pps_gpio_device_data),
GFP_KERNEL); GFP_KERNEL);
if (data == NULL) { if (data == NULL)
err = -ENOMEM; return -ENOMEM;
goto return_error;
}
/* initialize PPS specific parts of the bookkeeping data structure. */ /* initialize PPS specific parts of the bookkeeping data structure. */
data->info.mode = PPS_CAPTUREASSERT | PPS_OFFSETASSERT | data->info.mode = PPS_CAPTUREASSERT | PPS_OFFSETASSERT |
...@@ -152,41 +147,32 @@ static int pps_gpio_probe(struct platform_device *pdev) ...@@ -152,41 +147,32 @@ static int pps_gpio_probe(struct platform_device *pdev)
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) {
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; return -EINVAL;
goto return_error;
} }
data->irq = irq; data->irq = irq;
data->pdata = pdata; data->pdata = pdata;
/* register IRQ interrupt handler */ /* register IRQ interrupt handler */
ret = request_irq(irq, pps_gpio_irq_handler, ret = devm_request_irq(&pdev->dev, irq, pps_gpio_irq_handler,
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);
pr_err("failed to acquire IRQ %d\n", irq); pr_err("failed to acquire IRQ %d\n", irq);
err = -EINVAL; return -EINVAL;
goto return_error;
} }
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
dev_info(data->pps->dev, "Registered IRQ %d as PPS source\n", irq); dev_info(data->pps->dev, "Registered IRQ %d as PPS source\n", irq);
return 0; return 0;
return_error:
gpio_free(pdata->gpio_pin);
return err;
} }
static int pps_gpio_remove(struct platform_device *pdev) static int pps_gpio_remove(struct platform_device *pdev)
{ {
struct pps_gpio_device_data *data = platform_get_drvdata(pdev); struct pps_gpio_device_data *data = platform_get_drvdata(pdev);
const struct pps_gpio_platform_data *pdata = data->pdata;
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
free_irq(data->irq, data);
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);
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