[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20101109130425.GE15927@verge.net.au>
Date: Tue, 9 Nov 2010 22:04:25 +0900
From: Simon Horman <horms@...ge.net.au>
To: linux-kernel@...r.kernel.org
Cc: Anton Vorontsov <avorontsov@...mvista.com>,
David Brownell <dbrownell@...rs.sourceforge.net>
Subject: gpiolib: Questions about gpiochip_find_base()
Hi,
I have a few questions about gpiochip_find_base() which I hope someone can
help with.
* At the end of gpiochip_add() there is the following code:
if (gpio_is_valid(base))
pr_debug("%s: found new base at %d\n", __func__, base);
return base;
It is unclear to me why !gpio_is_valid(base) isn't an error condition
given that the following appears in gpiochip_add(), the caller of
gpiochip_find_base(), in the case where base isn't to be dynamic
selected.
if ((!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio - 1))
&& base >= 0) {
status = -EINVAL;
goto fail;
}
* In the same vein, its unclear to me why
the loop in gpiochip_find_base() checks values of i
that may not be valid according to gpio_is_valid().
Specifically I am wondering why
for (i = ARCH_NR_GPIOS - 1; i >= 0 ; i--) {
...
if (!chip && !test_bit(FLAG_RESERVED, &desc->flags)) {
...
isn't something like
for (i = ARCH_NR_GPIOS - 1; i >= 0 ; i--) {
...
if (gpio_is_valid(i) && !chip &&
!test_bit(FLAG_RESERVED, &desc->flags)) {
...
* I am wondering if in gpiochip_add() the following is unnecessary
in the case where base is dynamic as gpiochip_add() seems to
ensure that gpio_desc[id].chip is NULL for the dynamically selected range.
for (id = base; id < base + chip->ngpio; id++) {
if (gpio_desc[id].chip != NULL) {
status = -EBUSY;
break;
}
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists