* [PATCH] gpiolib: Don't allow drivers to specify a base with DT
@ 2014-07-31 12:07 Mark Brown
2014-08-04 4:21 ` Alexandre Courbot
2014-08-11 7:26 ` Linus Walleij
0 siblings, 2 replies; 5+ messages in thread
From: Mark Brown @ 2014-07-31 12:07 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot
Cc: linux-gpio, linux-kernel, linaro-kernel, Mark Brown
From: Mark Brown <broonie@linaro.org>
DT based systems should have no reason to use fixed GPIO numbers but some
drivers that work on both DT and non-DT platforms specify them anyway. In
order to improve robustness in cases where drivers use gpio_is_valid() to
check for a valid GPIO on data initialized to zero as a default and avoid
bugs due to assuptions about fixed numbers creeping in ignore any specified
base when DT is in use.
Signed-off-by: Mark Brown <broonie@linaro.org>
---
drivers/gpio/gpiolib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 768f0831db18..11d3cf1cbca7 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -234,7 +234,7 @@ int gpiochip_add(struct gpio_chip *chip)
spin_lock_irqsave(&gpio_lock, flags);
- if (base < 0) {
+ if (base < 0 || of_have_populated_dt()) {
base = gpiochip_find_base(chip->ngpio);
if (base < 0) {
status = base;
--
2.0.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] gpiolib: Don't allow drivers to specify a base with DT
2014-07-31 12:07 [PATCH] gpiolib: Don't allow drivers to specify a base with DT Mark Brown
@ 2014-08-04 4:21 ` Alexandre Courbot
2014-08-11 12:38 ` Mark Brown
2014-08-11 7:26 ` Linus Walleij
1 sibling, 1 reply; 5+ messages in thread
From: Alexandre Courbot @ 2014-08-04 4:21 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, linux-gpio@vger.kernel.org,
Linux Kernel Mailing List, linaro-kernel, Mark Brown
On Thu, Jul 31, 2014 at 9:07 PM, Mark Brown <broonie@kernel.org> wrote:
> From: Mark Brown <broonie@linaro.org>
>
> DT based systems should have no reason to use fixed GPIO numbers but some
> drivers that work on both DT and non-DT platforms specify them anyway. In
> order to improve robustness in cases where drivers use gpio_is_valid() to
> check for a valid GPIO on data initialized to zero as a default and avoid
> bugs due to assuptions about fixed numbers creeping in ignore any specified
> base when DT is in use.
I agree that DT users should not use the base number at all - but the
fact is some of them are doing it. Aren't we going to break some
user-space users that will expect to find a GPIO under a given number?
Also, how is this going to help with gpio_is_valid() against
zero-initialized data?
>
> Signed-off-by: Mark Brown <broonie@linaro.org>
> ---
> drivers/gpio/gpiolib.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 768f0831db18..11d3cf1cbca7 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -234,7 +234,7 @@ int gpiochip_add(struct gpio_chip *chip)
>
> spin_lock_irqsave(&gpio_lock, flags);
>
> - if (base < 0) {
> + if (base < 0 || of_have_populated_dt()) {
> base = gpiochip_find_base(chip->ngpio);
> if (base < 0) {
> status = base;
> --
> 2.0.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpiolib: Don't allow drivers to specify a base with DT
2014-07-31 12:07 [PATCH] gpiolib: Don't allow drivers to specify a base with DT Mark Brown
2014-08-04 4:21 ` Alexandre Courbot
@ 2014-08-11 7:26 ` Linus Walleij
2014-08-11 12:31 ` Mark Brown
1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2014-08-11 7:26 UTC (permalink / raw)
To: Mark Brown
Cc: Alexandre Courbot, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, linaro-kernel, Mark Brown
On Thu, Jul 31, 2014 at 2:07 PM, Mark Brown <broonie@kernel.org> wrote:
> From: Mark Brown <broonie@linaro.org>
>
> DT based systems should have no reason to use fixed GPIO numbers but some
> drivers that work on both DT and non-DT platforms specify them anyway. In
> order to improve robustness in cases where drivers use gpio_is_valid() to
> check for a valid GPIO on data initialized to zero as a default and avoid
> bugs due to assuptions about fixed numbers creeping in ignore any specified
> base when DT is in use.
Hm in principle you are right...
> - if (base < 0) {
> + if (base < 0 || of_have_populated_dt()) {
> base = gpiochip_find_base(chip->ngpio);
But here I worry about breaking in-transition systems, e.g.
defining part of the peripherals through DT but adding a
GPIO device with AUXDATA, setting up base that way.
Not that it should stay that way for sure, but it does need
some consideration...
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpiolib: Don't allow drivers to specify a base with DT
2014-08-11 7:26 ` Linus Walleij
@ 2014-08-11 12:31 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2014-08-11 12:31 UTC (permalink / raw)
To: Linus Walleij
Cc: Alexandre Courbot, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, linaro-kernel
[-- Attachment #1: Type: text/plain, Size: 616 bytes --]
On Mon, Aug 11, 2014 at 09:26:49AM +0200, Linus Walleij wrote:
> On Thu, Jul 31, 2014 at 2:07 PM, Mark Brown <broonie@kernel.org> wrote:
> > - if (base < 0) {
> > + if (base < 0 || of_have_populated_dt()) {
> > base = gpiochip_find_base(chip->ngpio);
> But here I worry about breaking in-transition systems, e.g.
> defining part of the peripherals through DT but adding a
> GPIO device with AUXDATA, setting up base that way.
> Not that it should stay that way for sure, but it does need
> some consideration...
Could we add a flag that the boards can use to override this behaviour?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpiolib: Don't allow drivers to specify a base with DT
2014-08-04 4:21 ` Alexandre Courbot
@ 2014-08-11 12:38 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2014-08-11 12:38 UTC (permalink / raw)
To: Alexandre Courbot
Cc: Linus Walleij, linux-gpio@vger.kernel.org,
Linux Kernel Mailing List, linaro-kernel
[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]
On Mon, Aug 04, 2014 at 01:21:57PM +0900, Alexandre Courbot wrote:
> On Thu, Jul 31, 2014 at 9:07 PM, Mark Brown <broonie@kernel.org> wrote:
> > DT based systems should have no reason to use fixed GPIO numbers but some
> > drivers that work on both DT and non-DT platforms specify them anyway. In
> > order to improve robustness in cases where drivers use gpio_is_valid() to
> > check for a valid GPIO on data initialized to zero as a default and avoid
> > bugs due to assuptions about fixed numbers creeping in ignore any specified
> > base when DT is in use.
> I agree that DT users should not use the base number at all - but the
> fact is some of them are doing it. Aren't we going to break some
> user-space users that will expect to find a GPIO under a given number?
Is this actually a realistic thing that people do with mainline - I'm
not convinced that it's going to be robust in general (a lot of DT
conversions will have broken things for entire architectures) and hard
coded numbers aren't the sort of things that make it into distros.
> Also, how is this going to help with gpio_is_valid() against
> zero-initialized data?
I should have said check for zero instead, sorry - though making 0 not
be a valid GPIO would help overall.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-11 12:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-31 12:07 [PATCH] gpiolib: Don't allow drivers to specify a base with DT Mark Brown
2014-08-04 4:21 ` Alexandre Courbot
2014-08-11 12:38 ` Mark Brown
2014-08-11 7:26 ` Linus Walleij
2014-08-11 12:31 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).