Skip to content

Commit fceb7ab

Browse files
committed
gpio: ws16c48: 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 bde8c0e commit fceb7ab

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

drivers/gpio/gpio-ws16c48.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,25 @@ static const char *ws16c48_names[WS16C48_NGPIO] = {
365365
"Port 5 Bit 4", "Port 5 Bit 5", "Port 5 Bit 6", "Port 5 Bit 7"
366366
};
367367

368+
static int ws16c48_irq_init_hw(struct gpio_chip *gc)
369+
{
370+
struct ws16c48_gpio *const ws16c48gpio = gpiochip_get_data(gc);
371+
372+
/* Disable IRQ by default */
373+
outb(0x80, ws16c48gpio->base + 7);
374+
outb(0, ws16c48gpio->base + 8);
375+
outb(0, ws16c48gpio->base + 9);
376+
outb(0, ws16c48gpio->base + 10);
377+
outb(0xC0, ws16c48gpio->base + 7);
378+
379+
return 0;
380+
}
381+
368382
static int ws16c48_probe(struct device *dev, unsigned int id)
369383
{
370384
struct ws16c48_gpio *ws16c48gpio;
371385
const char *const name = dev_name(dev);
386+
struct gpio_irq_chip *girq;
372387
int err;
373388

374389
ws16c48gpio = devm_kzalloc(dev, sizeof(*ws16c48gpio), GFP_KERNEL);
@@ -396,6 +411,16 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
396411
ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple;
397412
ws16c48gpio->base = base[id];
398413

414+
girq = &ws16c48gpio->chip.irq;
415+
girq->chip = &ws16c48_irqchip;
416+
/* This will let us handle the parent IRQ in the driver */
417+
girq->parent_handler = NULL;
418+
girq->num_parents = 0;
419+
girq->parents = NULL;
420+
girq->default_type = IRQ_TYPE_NONE;
421+
girq->handler = handle_edge_irq;
422+
girq->init_hw = ws16c48_irq_init_hw;
423+
399424
raw_spin_lock_init(&ws16c48gpio->lock);
400425

401426
err = devm_gpiochip_add_data(dev, &ws16c48gpio->chip, ws16c48gpio);
@@ -404,20 +429,6 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
404429
return err;
405430
}
406431

407-
/* Disable IRQ by default */
408-
outb(0x80, base[id] + 7);
409-
outb(0, base[id] + 8);
410-
outb(0, base[id] + 9);
411-
outb(0, base[id] + 10);
412-
outb(0xC0, base[id] + 7);
413-
414-
err = gpiochip_irqchip_add(&ws16c48gpio->chip, &ws16c48_irqchip, 0,
415-
handle_edge_irq, IRQ_TYPE_NONE);
416-
if (err) {
417-
dev_err(dev, "Could not add irqchip (%d)\n", err);
418-
return err;
419-
}
420-
421432
err = devm_request_irq(dev, irq[id], ws16c48_irq_handler, IRQF_SHARED,
422433
name, ws16c48gpio);
423434
if (err) {

0 commit comments

Comments
 (0)