diff mbox

[v2] gpio/gpiolib: Forbid irqchip default trigger if probed over DT

Message ID 1473235931-19079-1-git-send-email-marc.zyngier@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marc Zyngier Sept. 7, 2016, 8:12 a.m. UTC
Using a default trigger is a bad idea if using DT to configure
interrupts, as the device's interrupt specifier will always contain
the trigger configuration.

Let's warn about that particular situation, and revert to not
having a default. Hopefully, the couple of drivers still using
this feature will quickly be fixed.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
Send the tested patch this time around...

 drivers/gpio/gpiolib.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Linus Walleij Sept. 7, 2016, 10:18 p.m. UTC | #1
On Wed, Sep 7, 2016 at 10:12 AM, Marc Zyngier <marc.zyngier@arm.com> wrote:

> Using a default trigger is a bad idea if using DT to configure
> interrupts, as the device's interrupt specifier will always contain
> the trigger configuration.
>
> Let's warn about that particular situation, and revert to not
> having a default. Hopefully, the couple of drivers still using
> this feature will quickly be fixed.
>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> Send the tested patch this time around...

I got it the first time, don't worry :D

Yours,
Linus Walleij
Marc Zyngier Sept. 8, 2016, 5:13 p.m. UTC | #2
On 07/09/16 23:18, Linus Walleij wrote:
> On Wed, Sep 7, 2016 at 10:12 AM, Marc Zyngier <marc.zyngier@arm.com> wrote:
> 
>> Using a default trigger is a bad idea if using DT to configure
>> interrupts, as the device's interrupt specifier will always contain
>> the trigger configuration.
>>
>> Let's warn about that particular situation, and revert to not
>> having a default. Hopefully, the couple of drivers still using
>> this feature will quickly be fixed.
>>
>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>> Send the tested patch this time around...
> 
> I got it the first time, don't worry :D

Errrr, the first one didn't even compile (I'm such a moron sometimes).
Please apply this one instead, which has actually been compile-tested.

Sorry for the noise.

Thanks,

	M.
Linus Walleij Sept. 12, 2016, 9:05 a.m. UTC | #3
On Thu, Sep 8, 2016 at 7:13 PM, Marc Zyngier <marc.zyngier@arm.com> wrote:
> On 07/09/16 23:18, Linus Walleij wrote:
>> On Wed, Sep 7, 2016 at 10:12 AM, Marc Zyngier <marc.zyngier@arm.com> wrote:
>>
>>> Using a default trigger is a bad idea if using DT to configure
>>> interrupts, as the device's interrupt specifier will always contain
>>> the trigger configuration.
>>>
>>> Let's warn about that particular situation, and revert to not
>>> having a default. Hopefully, the couple of drivers still using
>>> this feature will quickly be fixed.
>>>
>>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>>> ---
>>> Send the tested patch this time around...
>>
>> I got it the first time, don't worry :D
>
> Errrr, the first one didn't even compile (I'm such a moron sometimes).
> Please apply this one instead, which has actually been compile-tested.
>
> Sorry for the noise.

Sending premature patches is human.

Backed the buggy one out and applied this instead!

Yours,
Linus Walleij
diff mbox

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 53ff25a..5707b5d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1617,6 +1617,15 @@  int _gpiochip_irqchip_add(struct gpio_chip *gpiochip,
 	if (gpiochip->of_node)
 		of_node = gpiochip->of_node;
 #endif
+	/*
+	 * Specifying a default trigger is a terrible idea if DT is
+	 * used to configure the interrupts, as you may end-up with
+	 * conflicting triggers. Tell the user, and reset to NONE.
+	 */
+	if (WARN(of_node && type != IRQ_TYPE_NONE,
+		 "%s: Ignoring %d default trigger\n", of_node->full_name, type))
+		type = IRQ_TYPE_NONE;
+
 	gpiochip->irqchip = irqchip;
 	gpiochip->irq_handler = handler;
 	gpiochip->irq_default_type = type;