summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpio-104-idio-16.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2020-07-22 12:55:17 +0200
committerLinus Walleij <linus.walleij@linaro.org>2020-07-23 15:10:25 +0200
commit82e4613d3d14c6551dd6d96896fd1b9e966afbab (patch)
tree5ccbce5c65fb768b9b5eedc7c6d039d2f35e843d /drivers/gpio/gpio-104-idio-16.c
parent44b01cf5d24286fe54301dca7a58afb8d01a1deb (diff)
gpio: 104-idio-16: Use irqchip template
This makes the driver use the irqchip template to assign properties to the gpio_irq_chip instead of using the explicit call to gpiochip_irqchip_add(). The irqchip is instead added while adding the gpiochip. Also move the IRQ initialization to the special .init_hw() callback. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com> Cc: William Breathitt Gray <vilhelm.gray@gmail.com> Link: https://lore.kernel.org/r/20200722105517.186137-1-linus.walleij@linaro.org
Diffstat (limited to 'drivers/gpio/gpio-104-idio-16.c')
-rw-r--r--drivers/gpio/gpio-104-idio-16.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
index 5752d9dab148..50ad0280fd78 100644
--- a/drivers/gpio/gpio-104-idio-16.c
+++ b/drivers/gpio/gpio-104-idio-16.c
@@ -224,10 +224,22 @@ static const char *idio_16_names[IDIO_16_NGPIO] = {
"IIN8", "IIN9", "IIN10", "IIN11", "IIN12", "IIN13", "IIN14", "IIN15"
};
+static int idio_16_irq_init_hw(struct gpio_chip *gc)
+{
+ struct idio_16_gpio *const idio16gpio = gpiochip_get_data(gc);
+
+ /* Disable IRQ by default */
+ outb(0, idio16gpio->base + 2);
+ outb(0, idio16gpio->base + 1);
+
+ return 0;
+}
+
static int idio_16_probe(struct device *dev, unsigned int id)
{
struct idio_16_gpio *idio16gpio;
const char *const name = dev_name(dev);
+ struct gpio_irq_chip *girq;
int err;
idio16gpio = devm_kzalloc(dev, sizeof(*idio16gpio), GFP_KERNEL);
@@ -256,6 +268,16 @@ static int idio_16_probe(struct device *dev, unsigned int id)
idio16gpio->base = base[id];
idio16gpio->out_state = 0xFFFF;
+ girq = &idio16gpio->chip.irq;
+ girq->chip = &idio_16_irqchip;
+ /* This will let us handle the parent IRQ in the driver */
+ girq->parent_handler = NULL;
+ girq->num_parents = 0;
+ girq->parents = NULL;
+ girq->default_type = IRQ_TYPE_NONE;
+ girq->handler = handle_edge_irq;
+ girq->init_hw = idio_16_irq_init_hw;
+
raw_spin_lock_init(&idio16gpio->lock);
err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio);
@@ -264,17 +286,6 @@ static int idio_16_probe(struct device *dev, unsigned int id)
return err;
}
- /* Disable IRQ by default */
- outb(0, base[id] + 2);
- outb(0, base[id] + 1);
-
- err = gpiochip_irqchip_add(&idio16gpio->chip, &idio_16_irqchip, 0,
- handle_edge_irq, IRQ_TYPE_NONE);
- if (err) {
- dev_err(dev, "Could not add irqchip (%d)\n", err);
- return err;
- }
-
err = devm_request_irq(dev, irq[id], idio_16_irq_handler, 0, name,
idio16gpio);
if (err) {