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

gpio: ws16c48: Utilize devm_ functions in driver probe callback

The devm_ resource manager functions allow memory to be automatically
released when a device is unbound. This patch takes advantage of the
resource manager functions and replaces the gpiochip_add_data call and
request_irq call with the devm_gpiochip_add_data call and
devm_request_irq call respectively. In addition, the ws16c48_remove
function has been removed as no longer necessary due to the use of the
relevant devm_ resource manager functions.
Signed-off-by: default avatarWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 2141b0a1
...@@ -46,7 +46,6 @@ MODULE_PARM_DESC(irq, "WinSystems WS16C48 interrupt line numbers"); ...@@ -46,7 +46,6 @@ MODULE_PARM_DESC(irq, "WinSystems WS16C48 interrupt line numbers");
* @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
* @irq: Interrupt line number
*/ */
struct ws16c48_gpio { struct ws16c48_gpio {
struct gpio_chip chip; struct gpio_chip chip;
...@@ -56,7 +55,6 @@ struct ws16c48_gpio { ...@@ -56,7 +55,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 irq;
}; };
static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
...@@ -371,13 +369,12 @@ static int ws16c48_probe(struct device *dev, unsigned int id) ...@@ -371,13 +369,12 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
ws16c48gpio->chip.set = ws16c48_gpio_set; ws16c48gpio->chip.set = ws16c48_gpio_set;
ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple; ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple;
ws16c48gpio->base = base[id]; ws16c48gpio->base = base[id];
ws16c48gpio->irq = irq[id];
spin_lock_init(&ws16c48gpio->lock); spin_lock_init(&ws16c48gpio->lock);
dev_set_drvdata(dev, ws16c48gpio); dev_set_drvdata(dev, ws16c48gpio);
err = gpiochip_add_data(&ws16c48gpio->chip, ws16c48gpio); err = devm_gpiochip_add_data(dev, &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);
return err; return err;
...@@ -394,30 +391,16 @@ static int ws16c48_probe(struct device *dev, unsigned int id) ...@@ -394,30 +391,16 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
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_remove; return err;
} }
err = request_irq(irq[id], ws16c48_irq_handler, IRQF_SHARED, name, err = devm_request_irq(dev, irq[id], ws16c48_irq_handler, IRQF_SHARED,
ws16c48gpio); name, 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_gpiochip_remove; return err;
} }
return 0;
err_gpiochip_remove:
gpiochip_remove(&ws16c48gpio->chip);
return err;
}
static int ws16c48_remove(struct device *dev, unsigned int id)
{
struct ws16c48_gpio *const ws16c48gpio = dev_get_drvdata(dev);
free_irq(ws16c48gpio->irq, ws16c48gpio);
gpiochip_remove(&ws16c48gpio->chip);
return 0; return 0;
} }
...@@ -426,7 +409,6 @@ static struct isa_driver ws16c48_driver = { ...@@ -426,7 +409,6 @@ static struct isa_driver ws16c48_driver = {
.driver = { .driver = {
.name = "ws16c48" .name = "ws16c48"
}, },
.remove = ws16c48_remove
}; };
module_isa_driver(ws16c48_driver, num_ws16c48); module_isa_driver(ws16c48_driver, num_ws16c48);
......
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