Commit 148ad68b authored by William Breathitt Gray's avatar William Breathitt Gray Committed by Linus Walleij

gpio: ws16c48: Use devm_request_region

By the time request_region is called in the WinSystems WS16C48 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 13441457
...@@ -41,7 +41,6 @@ MODULE_PARM_DESC(ws16c48_irq, "WinSystems WS16C48 interrupt line number"); ...@@ -41,7 +41,6 @@ MODULE_PARM_DESC(ws16c48_irq, "WinSystems WS16C48 interrupt line number");
* @irq_mask: I/O bits affected by interrupts * @irq_mask: I/O bits affected by interrupts
* @flow_mask: IRQ flow type mask for the respective I/O bits * @flow_mask: IRQ flow type mask for the respective I/O bits
* @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
*/ */
struct ws16c48_gpio { struct ws16c48_gpio {
...@@ -52,7 +51,6 @@ struct ws16c48_gpio { ...@@ -52,7 +51,6 @@ struct ws16c48_gpio {
unsigned long irq_mask; unsigned long irq_mask;
unsigned long flow_mask; unsigned long flow_mask;
unsigned base; unsigned base;
unsigned extent;
unsigned irq; unsigned irq;
}; };
...@@ -314,11 +312,10 @@ static int __init ws16c48_probe(struct platform_device *pdev) ...@@ -314,11 +312,10 @@ static int __init ws16c48_probe(struct platform_device *pdev)
if (!ws16c48gpio) if (!ws16c48gpio)
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;
} }
ws16c48gpio->chip.label = name; ws16c48gpio->chip.label = name;
...@@ -332,7 +329,6 @@ static int __init ws16c48_probe(struct platform_device *pdev) ...@@ -332,7 +329,6 @@ static int __init ws16c48_probe(struct platform_device *pdev)
ws16c48gpio->chip.get = ws16c48_gpio_get; ws16c48gpio->chip.get = ws16c48_gpio_get;
ws16c48gpio->chip.set = ws16c48_gpio_set; ws16c48gpio->chip.set = ws16c48_gpio_set;
ws16c48gpio->base = base; ws16c48gpio->base = base;
ws16c48gpio->extent = extent;
ws16c48gpio->irq = irq; ws16c48gpio->irq = irq;
spin_lock_init(&ws16c48gpio->lock); spin_lock_init(&ws16c48gpio->lock);
...@@ -342,7 +338,7 @@ static int __init ws16c48_probe(struct platform_device *pdev) ...@@ -342,7 +338,7 @@ static int __init ws16c48_probe(struct platform_device *pdev)
err = gpiochip_add_data(&ws16c48gpio->chip, ws16c48gpio); err = gpiochip_add_data(&ws16c48gpio->chip, ws16c48gpio);
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 */
...@@ -356,24 +352,20 @@ static int __init ws16c48_probe(struct platform_device *pdev) ...@@ -356,24 +352,20 @@ static int __init ws16c48_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, ws16c48_irq_handler, IRQF_SHARED, name, err = request_irq(irq, ws16c48_irq_handler, IRQF_SHARED, name,
ws16c48gpio); ws16c48gpio);
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(&ws16c48gpio->chip); gpiochip_remove(&ws16c48gpio->chip);
err_gpio_register:
release_region(base, extent);
err_lock_io_port:
return err; return err;
} }
...@@ -383,7 +375,6 @@ static int ws16c48_remove(struct platform_device *pdev) ...@@ -383,7 +375,6 @@ static int ws16c48_remove(struct platform_device *pdev)
free_irq(ws16c48gpio->irq, ws16c48gpio); free_irq(ws16c48gpio->irq, ws16c48gpio);
gpiochip_remove(&ws16c48gpio->chip); gpiochip_remove(&ws16c48gpio->chip);
release_region(ws16c48gpio->base, ws16c48gpio->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