Skip to content

Commit 44b01cf

Browse files
committed
gpio: 104-idi-48: 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 2fa1d39 commit 44b01cf

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

drivers/gpio/gpio-104-idi-48.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,22 @@ static const char *idi48_names[IDI48_NGPIO] = {
247247
"Bit 18 B", "Bit 19 B", "Bit 20 B", "Bit 21 B", "Bit 22 B", "Bit 23 B"
248248
};
249249

250+
static int idi_48_irq_init_hw(struct gpio_chip *gc)
251+
{
252+
struct idi_48_gpio *const idi48gpio = gpiochip_get_data(gc);
253+
254+
/* Disable IRQ by default */
255+
outb(0, idi48gpio->base + 7);
256+
inb(idi48gpio->base + 7);
257+
258+
return 0;
259+
}
260+
250261
static int idi_48_probe(struct device *dev, unsigned int id)
251262
{
252263
struct idi_48_gpio *idi48gpio;
253264
const char *const name = dev_name(dev);
265+
struct gpio_irq_chip *girq;
254266
int err;
255267

256268
idi48gpio = devm_kzalloc(dev, sizeof(*idi48gpio), GFP_KERNEL);
@@ -275,6 +287,16 @@ static int idi_48_probe(struct device *dev, unsigned int id)
275287
idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple;
276288
idi48gpio->base = base[id];
277289

290+
girq = &idi48gpio->chip.irq;
291+
girq->chip = &idi_48_irqchip;
292+
/* This will let us handle the parent IRQ in the driver */
293+
girq->parent_handler = NULL;
294+
girq->num_parents = 0;
295+
girq->parents = NULL;
296+
girq->default_type = IRQ_TYPE_NONE;
297+
girq->handler = handle_edge_irq;
298+
girq->init_hw = idi_48_irq_init_hw;
299+
278300
raw_spin_lock_init(&idi48gpio->lock);
279301
spin_lock_init(&idi48gpio->ack_lock);
280302

@@ -284,17 +306,6 @@ static int idi_48_probe(struct device *dev, unsigned int id)
284306
return err;
285307
}
286308

287-
/* Disable IRQ by default */
288-
outb(0, base[id] + 7);
289-
inb(base[id] + 7);
290-
291-
err = gpiochip_irqchip_add(&idi48gpio->chip, &idi_48_irqchip, 0,
292-
handle_edge_irq, IRQ_TYPE_NONE);
293-
if (err) {
294-
dev_err(dev, "Could not add irqchip (%d)\n", err);
295-
return err;
296-
}
297-
298309
err = devm_request_irq(dev, irq[id], idi_48_irq_handler, IRQF_SHARED,
299310
name, idi48gpio);
300311
if (err) {

0 commit comments

Comments
 (0)