Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96b2cca6 authored by Linus Walleij's avatar Linus Walleij
Browse files

gpio: stmpe: forbid unused lines to be mapped as IRQs



Exploit the new mechanism for masking off disallowed IRQs
added by Mika Westerberg to properly manage the STMPE
"norequest mask" to disallow also mapping said lines as
IRQs.

Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: default avatarPatrice Chotard <patrice.chotard@st.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent ac2a8bca
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -13,6 +13,7 @@
#include <linux/of.h>
#include <linux/of.h>
#include <linux/mfd/stmpe.h>
#include <linux/mfd/stmpe.h>
#include <linux/seq_file.h>
#include <linux/seq_file.h>
#include <linux/bitops.h>


/*
/*
 * These registers are modified under the irq bus lock and cached to avoid
 * These registers are modified under the irq bus lock and cached to avoid
@@ -449,6 +450,8 @@ static int stmpe_gpio_probe(struct platform_device *pdev)


	of_property_read_u32(np, "st,norequest-mask",
	of_property_read_u32(np, "st,norequest-mask",
			&stmpe_gpio->norequest_mask);
			&stmpe_gpio->norequest_mask);
	if (stmpe_gpio->norequest_mask)
		stmpe_gpio->chip.irq_need_valid_mask = true;


	if (irq < 0)
	if (irq < 0)
		dev_info(&pdev->dev,
		dev_info(&pdev->dev,
@@ -473,6 +476,14 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
			dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
			dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
			goto out_disable;
			goto out_disable;
		}
		}
		if (stmpe_gpio->norequest_mask) {
			int i;

			/* Forbid unused lines to be mapped as IRQs */
			for (i = 0; i < sizeof(u32); i++)
				if (stmpe_gpio->norequest_mask & BIT(i))
					clear_bit(i, stmpe_gpio->chip.irq_valid_mask);
		}
		ret =  gpiochip_irqchip_add(&stmpe_gpio->chip,
		ret =  gpiochip_irqchip_add(&stmpe_gpio->chip,
					    &stmpe_gpio_irq_chip,
					    &stmpe_gpio_irq_chip,
					    0,
					    0,