From: Simon Horman <horms@verge.net.au>
To: linux-kernel@vger.kernel.org
Cc: Anton Vorontsov <avorontsov@ru.mvista.com>,
David Brownell <dbrownell@users.sourceforge.net>
Subject: gpiolib: Questions about gpiochip_find_base()
Date: Tue, 9 Nov 2010 22:04:25 +0900 [thread overview]
Message-ID: <20101109130425.GE15927@verge.net.au> (raw)
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;
}
}
reply other threads:[~2010-11-09 13:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101109130425.GE15927@verge.net.au \
--to=horms@verge.net.au \
--cc=avorontsov@ru.mvista.com \
--cc=dbrownell@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®