Skip to content

Commit dfc3a26

Browse files
committed
gpio: adp5588: 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]> Acked-by: Michael Hennerich <[email protected]> Cc: Nikolaus Voss <[email protected]> Cc: Michael Hennerich <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 565a0e9 commit dfc3a26

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

drivers/gpio/gpio-adp5588.c

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,24 @@ static irqreturn_t adp5588_irq_handler(int irq, void *devid)
272272
return IRQ_HANDLED;
273273
}
274274

275+
276+
static int adp5588_irq_init_hw(struct gpio_chip *gc)
277+
{
278+
struct adp5588_gpio *dev = gpiochip_get_data(gc);
279+
/* Enable IRQs after registering chip */
280+
adp5588_gpio_write(dev->client, CFG,
281+
ADP5588_AUTO_INC | ADP5588_INT_CFG | ADP5588_KE_IEN);
282+
283+
return 0;
284+
}
285+
275286
static int adp5588_irq_setup(struct adp5588_gpio *dev)
276287
{
277288
struct i2c_client *client = dev->client;
278289
int ret;
279290
struct adp5588_gpio_platform_data *pdata =
280291
dev_get_platdata(&client->dev);
281-
int irq_base = pdata ? pdata->irq_base : 0;
292+
struct gpio_irq_chip *girq;
282293

283294
adp5588_gpio_write(client, CFG, ADP5588_AUTO_INC);
284295
adp5588_gpio_write(client, INT_STAT, -1); /* status is W1C */
@@ -294,21 +305,19 @@ static int adp5588_irq_setup(struct adp5588_gpio *dev)
294305
client->irq);
295306
return ret;
296307
}
297-
ret = gpiochip_irqchip_add_nested(&dev->gpio_chip,
298-
&adp5588_irq_chip, irq_base,
299-
handle_simple_irq,
300-
IRQ_TYPE_NONE);
301-
if (ret) {
302-
dev_err(&client->dev,
303-
"could not connect irqchip to gpiochip\n");
304-
return ret;
305-
}
306-
gpiochip_set_nested_irqchip(&dev->gpio_chip,
307-
&adp5588_irq_chip,
308-
client->irq);
309308

310-
adp5588_gpio_write(client, CFG,
311-
ADP5588_AUTO_INC | ADP5588_INT_CFG | ADP5588_KE_IEN);
309+
/* This will be registered in the call to devm_gpiochip_add_data() */
310+
girq = &dev->gpio_chip.irq;
311+
girq->chip = &adp5588_irq_chip;
312+
/* This will let us handle the parent IRQ in the driver */
313+
girq->parent_handler = NULL;
314+
girq->num_parents = 0;
315+
girq->parents = NULL;
316+
girq->first = pdata ? pdata->irq_base : 0;
317+
girq->default_type = IRQ_TYPE_NONE;
318+
girq->handler = handle_simple_irq;
319+
girq->init_hw = adp5588_irq_init_hw;
320+
girq->threaded = true;
312321

313322
return 0;
314323
}

0 commit comments

Comments
 (0)