From 5fbe5b5883f847363ff1b7280e8b1d2980526b8e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 4 Sep 2019 16:01:04 +0200 Subject: gpio: Initialize the irqchip valid_mask with a callback After changing the valid_mask for the struct gpio_chip to detect the need and presence of a valid mask with the presence of a .init_valid_mask() callback to fill it in, we augment the gpio_irq_chip to use the same logic. Switch all driver using the gpio_irq_chio valid_mask over to this new method. This makes sure the valid_mask for the gpio_irq_chip gets filled in when we add the gpio_chip, which makes it a little easier to switch over drivers using the old way of setting up gpio_irq_chip over to the new method of passing the gpio_irq_chip along with the gpio_chip. (See drivers/gpio/TODO for details.) Cc: Joel Stanley Cc: Thierry Reding Signed-off-by: Linus Walleij Reviewed-by: Andy Shevchenko Tested-by: Hans de Goede Reviewed-by: Andrew Jeffery Acked-by: Mika Westerberg Reviewed-by: Andrew Lunn Reviewed-by: Patrice Chotard Link: https://lore.kernel.org/r/20190904140104.32426-1-linus.walleij@linaro.org --- drivers/gpio/gpio-tqmx86.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'drivers/gpio/gpio-tqmx86.c') diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c index 07050cdbadb9..a3109bcaa0ac 100644 --- a/drivers/gpio/gpio-tqmx86.c +++ b/drivers/gpio/gpio-tqmx86.c @@ -214,6 +214,17 @@ static const struct dev_pm_ops tqmx86_gpio_dev_pm_ops = { tqmx86_gpio_runtime_resume, NULL) }; +static void tqmx86_init_irq_valid_mask(struct gpio_chip *chip, + unsigned long *valid_mask, + unsigned int ngpios) +{ + /* Only GPIOs 4-7 are valid for interrupts. Clear the others */ + clear_bit(0, valid_mask); + clear_bit(1, valid_mask); + clear_bit(2, valid_mask); + clear_bit(3, valid_mask); +} + static int tqmx86_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -260,7 +271,6 @@ static int tqmx86_gpio_probe(struct platform_device *pdev) chip->get = tqmx86_gpio_get; chip->set = tqmx86_gpio_set; chip->ngpio = TQMX86_NGPIO; - chip->irq.need_valid_mask = true; chip->parent = pdev->dev.parent; pm_runtime_enable(&pdev->dev); @@ -296,6 +306,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev) girq->parents[0] = irq; girq->default_type = IRQ_TYPE_NONE; girq->handler = handle_simple_irq; + girq->init_valid_mask = tqmx86_init_irq_valid_mask; } ret = devm_gpiochip_add_data(dev, chip, gpio); @@ -304,14 +315,6 @@ static int tqmx86_gpio_probe(struct platform_device *pdev) goto out_pm_dis; } - /* Only GPIOs 4-7 are valid for interrupts. Clear the others */ - if (irq) { - clear_bit(0, girq->valid_mask); - clear_bit(1, girq->valid_mask); - clear_bit(2, girq->valid_mask); - clear_bit(3, girq->valid_mask); - } - dev_info(dev, "GPIO functionality initialized with %d pins\n", chip->ngpio); -- cgit v1.2.3