Skip to content

Commit 50787be

Browse files
committed
gpio: pcf857x: Use irqchip template
This makes the driver use the irqchip template to assign properties to the gpio_irq_chip instead of using the explicit calls to gpiochip_irqchip_add_nested() and gpiochip_set_nested_irqchip(). The irqchip is instead added while adding the gpiochip. Signed-off-by: Linus Walleij <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Anders Darander <[email protected]> Cc: Roger Quadros <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent dfc3a26 commit 50787be

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

drivers/gpio/gpio-pcf857x.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -334,29 +334,19 @@ static int pcf857x_probe(struct i2c_client *client,
334334
gpio->out = ~n_latch;
335335
gpio->status = gpio->out;
336336

337-
status = devm_gpiochip_add_data(&client->dev, &gpio->chip, gpio);
338-
if (status < 0)
339-
goto fail;
340-
341337
/* Enable irqchip if we have an interrupt */
342338
if (client->irq) {
343-
gpio->irqchip.name = "pcf857x",
344-
gpio->irqchip.irq_enable = pcf857x_irq_enable,
345-
gpio->irqchip.irq_disable = pcf857x_irq_disable,
346-
gpio->irqchip.irq_ack = noop,
347-
gpio->irqchip.irq_mask = noop,
348-
gpio->irqchip.irq_unmask = noop,
349-
gpio->irqchip.irq_set_wake = pcf857x_irq_set_wake,
350-
gpio->irqchip.irq_bus_lock = pcf857x_irq_bus_lock,
351-
gpio->irqchip.irq_bus_sync_unlock = pcf857x_irq_bus_sync_unlock,
352-
status = gpiochip_irqchip_add_nested(&gpio->chip,
353-
&gpio->irqchip,
354-
0, handle_level_irq,
355-
IRQ_TYPE_NONE);
356-
if (status) {
357-
dev_err(&client->dev, "cannot add irqchip\n");
358-
goto fail;
359-
}
339+
struct gpio_irq_chip *girq;
340+
341+
gpio->irqchip.name = "pcf857x";
342+
gpio->irqchip.irq_enable = pcf857x_irq_enable;
343+
gpio->irqchip.irq_disable = pcf857x_irq_disable;
344+
gpio->irqchip.irq_ack = noop;
345+
gpio->irqchip.irq_mask = noop;
346+
gpio->irqchip.irq_unmask = noop;
347+
gpio->irqchip.irq_set_wake = pcf857x_irq_set_wake;
348+
gpio->irqchip.irq_bus_lock = pcf857x_irq_bus_lock;
349+
gpio->irqchip.irq_bus_sync_unlock = pcf857x_irq_bus_sync_unlock;
360350

361351
status = devm_request_threaded_irq(&client->dev, client->irq,
362352
NULL, pcf857x_irq, IRQF_ONESHOT |
@@ -365,10 +355,21 @@ static int pcf857x_probe(struct i2c_client *client,
365355
if (status)
366356
goto fail;
367357

368-
gpiochip_set_nested_irqchip(&gpio->chip, &gpio->irqchip,
369-
client->irq);
358+
girq = &gpio->chip.irq;
359+
girq->chip = &gpio->irqchip;
360+
/* This will let us handle the parent IRQ in the driver */
361+
girq->parent_handler = NULL;
362+
girq->num_parents = 0;
363+
girq->parents = NULL;
364+
girq->default_type = IRQ_TYPE_NONE;
365+
girq->handler = handle_level_irq;
366+
girq->threaded = true;
370367
}
371368

369+
status = devm_gpiochip_add_data(&client->dev, &gpio->chip, gpio);
370+
if (status < 0)
371+
goto fail;
372+
372373
/* Let platform code set up the GPIOs and their users.
373374
* Now is the first time anyone could use them.
374375
*/

0 commit comments

Comments
 (0)