Commit 5cfc0576 authored by William Breathitt Gray's avatar William Breathitt Gray Committed by Linus Walleij

gpio: 104-idi-48: Use devm_request_region

By the time request_region is called in the ACCES 104-IDI-48 GPIO
driver, a corresponding device structure has already been allocated. The
devm_request_region function should be used to help simplify the cleanup
code and reduce the possible points of failure.
Signed-off-by: default avatarWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent aa6c3602
...@@ -39,7 +39,6 @@ MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number"); ...@@ -39,7 +39,6 @@ MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number");
* @ack_lock: synchronization lock to prevent IRQ handler race conditions * @ack_lock: synchronization lock to prevent IRQ handler race conditions
* @irq_mask: input bits affected by interrupts * @irq_mask: input bits affected by interrupts
* @base: base port address of the GPIO device * @base: base port address of the GPIO device
* @extent: extent of port address region of the GPIO device
* @irq: Interrupt line number * @irq: Interrupt line number
* @cos_enb: Change-Of-State IRQ enable boundaries mask * @cos_enb: Change-Of-State IRQ enable boundaries mask
*/ */
...@@ -49,7 +48,6 @@ struct idi_48_gpio { ...@@ -49,7 +48,6 @@ struct idi_48_gpio {
spinlock_t ack_lock; spinlock_t ack_lock;
unsigned char irq_mask[6]; unsigned char irq_mask[6];
unsigned base; unsigned base;
unsigned extent;
unsigned irq; unsigned irq;
unsigned char cos_enb; unsigned char cos_enb;
}; };
...@@ -227,11 +225,10 @@ static int __init idi_48_probe(struct platform_device *pdev) ...@@ -227,11 +225,10 @@ static int __init idi_48_probe(struct platform_device *pdev)
if (!idi48gpio) if (!idi48gpio)
return -ENOMEM; return -ENOMEM;
if (!request_region(base, extent, name)) { if (!devm_request_region(dev, base, extent, name)) {
dev_err(dev, "Unable to lock %s port addresses (0x%X-0x%X)\n", dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
name, base, base + extent); base, base + extent);
err = -EBUSY; return -EBUSY;
goto err_lock_io_port;
} }
idi48gpio->chip.label = name; idi48gpio->chip.label = name;
...@@ -243,7 +240,6 @@ static int __init idi_48_probe(struct platform_device *pdev) ...@@ -243,7 +240,6 @@ static int __init idi_48_probe(struct platform_device *pdev)
idi48gpio->chip.direction_input = idi_48_gpio_direction_input; idi48gpio->chip.direction_input = idi_48_gpio_direction_input;
idi48gpio->chip.get = idi_48_gpio_get; idi48gpio->chip.get = idi_48_gpio_get;
idi48gpio->base = base; idi48gpio->base = base;
idi48gpio->extent = extent;
idi48gpio->irq = irq; idi48gpio->irq = irq;
spin_lock_init(&idi48gpio->lock); spin_lock_init(&idi48gpio->lock);
...@@ -253,7 +249,7 @@ static int __init idi_48_probe(struct platform_device *pdev) ...@@ -253,7 +249,7 @@ static int __init idi_48_probe(struct platform_device *pdev)
err = gpiochip_add_data(&idi48gpio->chip, idi48gpio); err = gpiochip_add_data(&idi48gpio->chip, idi48gpio);
if (err) { if (err) {
dev_err(dev, "GPIO registering failed (%d)\n", err); dev_err(dev, "GPIO registering failed (%d)\n", err);
goto err_gpio_register; return err;
} }
/* Disable IRQ by default */ /* Disable IRQ by default */
...@@ -264,24 +260,20 @@ static int __init idi_48_probe(struct platform_device *pdev) ...@@ -264,24 +260,20 @@ static int __init idi_48_probe(struct platform_device *pdev)
handle_edge_irq, IRQ_TYPE_NONE); handle_edge_irq, IRQ_TYPE_NONE);
if (err) { if (err) {
dev_err(dev, "Could not add irqchip (%d)\n", err); dev_err(dev, "Could not add irqchip (%d)\n", err);
goto err_gpiochip_irqchip_add; goto err_gpiochip_remove;
} }
err = request_irq(irq, idi_48_irq_handler, IRQF_SHARED, name, err = request_irq(irq, idi_48_irq_handler, IRQF_SHARED, name,
idi48gpio); idi48gpio);
if (err) { if (err) {
dev_err(dev, "IRQ handler registering failed (%d)\n", err); dev_err(dev, "IRQ handler registering failed (%d)\n", err);
goto err_request_irq; goto err_gpiochip_remove;
} }
return 0; return 0;
err_request_irq: err_gpiochip_remove:
err_gpiochip_irqchip_add:
gpiochip_remove(&idi48gpio->chip); gpiochip_remove(&idi48gpio->chip);
err_gpio_register:
release_region(base, extent);
err_lock_io_port:
return err; return err;
} }
...@@ -291,7 +283,6 @@ static int idi_48_remove(struct platform_device *pdev) ...@@ -291,7 +283,6 @@ static int idi_48_remove(struct platform_device *pdev)
free_irq(idi48gpio->irq, idi48gpio); free_irq(idi48gpio->irq, idi48gpio);
gpiochip_remove(&idi48gpio->chip); gpiochip_remove(&idi48gpio->chip);
release_region(idi48gpio->base, idi48gpio->extent);
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