Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756715Ab3H2TAf (ORCPT ); Thu, 29 Aug 2013 15:00:35 -0400 Received: from mail-oa0-f43.google.com ([209.85.219.43]:39983 "EHLO mail-oa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755419Ab3H2TAd (ORCPT ); Thu, 29 Aug 2013 15:00:33 -0400 MIME-Version: 1.0 In-Reply-To: <5217BD74.5030801@wwwdotorg.org> References: <1377092334-770-1-git-send-email-larsi@wh2.tu-dresden.de> <1507189.CRWvzVJqTV@flatron> <521548E3.6010703@wwwdotorg.org> <52167E5D.6060802@wwwdotorg.org> <5217BD74.5030801@wwwdotorg.org> Date: Thu, 29 Aug 2013 21:00:32 +0200 Message-ID: Subject: Re: [PATCH v2] gpio: interrupt consistency check for OF GPIO IRQs From: Linus Walleij To: Stephen Warren Cc: Tomasz Figa , Lars Poeschel , Lars Poeschel , Grant Likely , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , Mark Rutland , Ian Campbell , Kumar Gala , Pawel Moll , Javier Martinez Canillas , Enric Balletbo i Serra , Jean-Christophe PLAGNIOL-VILLARD , Santosh Shilimkar , Kevin Hilman , Balaji T K , Tony Lindgren , Jon Hunter Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2260 Lines: 60 On Fri, Aug 23, 2013 at 9:52 PM, Stephen Warren wrote: > On 08/23/2013 12:45 PM, Linus Walleij wrote: >> This is a perfectly OK thing to do as long as it is done like >> this: >> >> request_gpio(gpio); >> gpio_direction_input(gpio); >> request_irq(gpio_to_irq(gpio)); > > But I'm not aware that there's a rule saying it's illegal to: > > request_irq(gpio_to_irq(gpio)); > request_gpio(gpio); > gpio_direction_input(gpio); No but I think there should be one ... maybe I'm an oddball but it seems natural to request a GPIO before tying IRQs to fire off it. Besides, the bug that this is trying to solve is due to the fact that the OMAP driver require exactly the former order for the IRQs to work. I think if the sequence matters it is likely to be the first form, but it's a rough guess. >> Pass only the GPIO in the device tree and this works just fine. > > And I wouldn't be surprised if there were DTs that had separate GPIO and > interrupt entries for the same pin. That is the situation we want to catch. Don't you agree that it has some bit of ambiguity around it, like the tree makes an assumtion that whether you ask for the GPIO line or IRQ first does not matter, and leave it up to the driver to "do something" if the order suddenly turns out the other way around, but is important to the hardware? I think we can't get away from the ambition to define this semantic for all DT systems. > In fact, it's arguably technically > more correct to do that than just list the GPIO, and then hope the OS > will be able to convert it to the correct IRQ. Then, drivers wouldn't > have any reason to believe they needed a specific IRQ-vs-GPIO request > ordering. If that is more technically correct (hm I wonder what measure is used for "correctness" here) I think we are back at the GPIO input hogs to achive what OMAP needs. Using such hogs they can let the gpiochip node hog a few pins and set them as input rather than each and every driver having to do so. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/