Skip to content

Commit 4530a84

Browse files
committed
gpio: pci-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 <[email protected]> Acked-by: William Breathitt Gray <[email protected]> Cc: William Breathitt Gray <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 866e863 commit 4530a84

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

drivers/gpio/gpio-pci-idio-16.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,25 @@ static const char *idio_16_names[IDIO_16_NGPIO] = {
280280
"IIN8", "IIN9", "IIN10", "IIN11", "IIN12", "IIN13", "IIN14", "IIN15"
281281
};
282282

283+
static int idio_16_irq_init_hw(struct gpio_chip *gc)
284+
{
285+
struct idio_16_gpio *const idio16gpio = gpiochip_get_data(gc);
286+
287+
/* Disable IRQ by default and clear any pending interrupt */
288+
iowrite8(0, &idio16gpio->reg->irq_ctl);
289+
iowrite8(0, &idio16gpio->reg->in0_7);
290+
291+
return 0;
292+
}
293+
283294
static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id)
284295
{
285296
struct device *const dev = &pdev->dev;
286297
struct idio_16_gpio *idio16gpio;
287298
int err;
288299
const size_t pci_bar_index = 2;
289300
const char *const name = pci_name(pdev);
301+
struct gpio_irq_chip *girq;
290302

291303
idio16gpio = devm_kzalloc(dev, sizeof(*idio16gpio), GFP_KERNEL);
292304
if (!idio16gpio)
@@ -323,6 +335,16 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id)
323335
idio16gpio->chip.set = idio_16_gpio_set;
324336
idio16gpio->chip.set_multiple = idio_16_gpio_set_multiple;
325337

338+
girq = &idio16gpio->chip.irq;
339+
girq->chip = &idio_16_irqchip;
340+
/* This will let us handle the parent IRQ in the driver */
341+
girq->parent_handler = NULL;
342+
girq->num_parents = 0;
343+
girq->parents = NULL;
344+
girq->default_type = IRQ_TYPE_NONE;
345+
girq->handler = handle_edge_irq;
346+
girq->init_hw = idio_16_irq_init_hw;
347+
326348
raw_spin_lock_init(&idio16gpio->lock);
327349

328350
err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio);
@@ -331,17 +353,6 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id)
331353
return err;
332354
}
333355

334-
/* Disable IRQ by default and clear any pending interrupt */
335-
iowrite8(0, &idio16gpio->reg->irq_ctl);
336-
iowrite8(0, &idio16gpio->reg->in0_7);
337-
338-
err = gpiochip_irqchip_add(&idio16gpio->chip, &idio_16_irqchip, 0,
339-
handle_edge_irq, IRQ_TYPE_NONE);
340-
if (err) {
341-
dev_err(dev, "Could not add irqchip (%d)\n", err);
342-
return err;
343-
}
344-
345356
err = devm_request_irq(dev, pdev->irq, idio_16_irq_handler, IRQF_SHARED,
346357
name, idio16gpio);
347358
if (err) {

0 commit comments

Comments
 (0)