lkml.org 
[lkml]   [2010]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectgpiolib: 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;
}
}


\
 
 \ /
  Last update: 2010-11-09 14:07    [W:0.027 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site