summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpio-ws16c48.c
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>2017-01-24 15:01:15 -0500
committerLinus Walleij <linus.walleij@linaro.org>2017-01-26 15:56:30 +0100
commitb4cad1bc5ff63881b92a0fe9683723b4379d8c40 (patch)
tree086b3ee698cc44a24fe4836c39dc3b0ae0e4361d /drivers/gpio/gpio-ws16c48.c
parent2141b0a1d718d5f75b581530ef4f9641c7c4284c (diff)
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: William Breathitt Gray <vilhelm.gray@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-ws16c48.c')
-rw-r--r--drivers/gpio/gpio-ws16c48.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index 25e539530c08..65de20dfbe7a 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -46,7 +46,6 @@ MODULE_PARM_DESC(irq, "WinSystems WS16C48 interrupt line numbers");
* @irq_mask: I/O bits affected by interrupts
* @flow_mask: IRQ flow type mask for the respective I/O bits
* @base: base port address of the GPIO device
- * @irq: Interrupt line number
*/
struct ws16c48_gpio {
struct gpio_chip chip;
@@ -56,7 +55,6 @@ struct ws16c48_gpio {
unsigned long irq_mask;
unsigned long flow_mask;
unsigned base;
- unsigned irq;
};
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)
ws16c48gpio->chip.set = ws16c48_gpio_set;
ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple;
ws16c48gpio->base = base[id];
- ws16c48gpio->irq = irq[id];
spin_lock_init(&ws16c48gpio->lock);
dev_set_drvdata(dev, ws16c48gpio);
- err = gpiochip_add_data(&ws16c48gpio->chip, ws16c48gpio);
+ err = devm_gpiochip_add_data(dev, &ws16c48gpio->chip, ws16c48gpio);
if (err) {
dev_err(dev, "GPIO registering failed (%d)\n", err);
return err;
@@ -394,31 +391,17 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
handle_edge_irq, IRQ_TYPE_NONE);
if (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,
- ws16c48gpio);
+ err = devm_request_irq(dev, irq[id], ws16c48_irq_handler, IRQF_SHARED,
+ name, ws16c48gpio);
if (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;
}
static struct isa_driver ws16c48_driver = {
@@ -426,7 +409,6 @@ static struct isa_driver ws16c48_driver = {
.driver = {
.name = "ws16c48"
},
- .remove = ws16c48_remove
};
module_isa_driver(ws16c48_driver, num_ws16c48);