From: "Magnus Damm" <magnus.damm@gmail.com>
To: "David Brownell" <david-b@pacbell.net>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [patch 2.6.27-rc7] gpiolib: request/free hooks
Date: Sun, 28 Sep 2008 00:00:24 +0900 [thread overview]
Message-ID: <aec7e5c30809270800y7a4b59eem8af480d5899a791a@mail.gmail.com> (raw)
In-Reply-To: <200809241508.11091.david-b@pacbell.net>
Hi David,
On Thu, Sep 25, 2008 at 7:08 AM, David Brownell <david-b@pacbell.net> wrote:
> From: David Brownell <dbrownell@users.sourceforge.net>
>
> Add a new internal mechanism to gpiolib to support low power
> operations by letting gpio_chip instances see when their GPIOs
> are in use. When no GPIOs are active, chips may be able to
> enter lower powered runtime states by disabling clocks and/or
> power domains.
>
> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Looking good. I'm currently hacking on some pinmuxed gpio code for
SuperH, and I'd like to use these request/free callbacks to select
proper pinmux state.
I have one comment below though:
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -781,6 +785,7 @@ EXPORT_SYMBOL_GPL(gpiochip_remove);
> int gpio_request(unsigned gpio, const char *label)
> {
> struct gpio_desc *desc;
> + struct gpio_chip *chip;
> int status = -EINVAL;
> unsigned long flags;
>
> @@ -789,22 +794,31 @@ int gpio_request(unsigned gpio, const ch
> if (!gpio_is_valid(gpio))
> goto done;
> desc = &gpio_desc[gpio];
> - if (desc->chip == NULL)
> + chip = desc->chip;
> + if (chip == NULL)
> goto done;
>
> - if (!try_module_get(desc->chip->owner))
> + if (!try_module_get(chip->owner))
> goto done;
>
> /* NOTE: gpio_request() can be called in early boot,
> - * before IRQs are enabled.
> + * before IRQs are enabled, for non-sleeping (SOC) GPIOs.
> */
>
> + if (chip->request) {
> + status = chip->request(chip, gpio - chip->base);
> + if (status < 0) {
> + module_put(chip->owner);
> + goto done;
> + }
> + }
> +
> if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) {
> desc_set_label(desc, label ? : "?");
> status = 0;
> } else {
> status = -EBUSY;
> - module_put(desc->chip->owner);
> + module_put(chip->owner);
> }
>
> done:
The code above doesn't catch double gpio_request() user calls
properly. Or rather, the user will receive an error but the
chip->request() callback may get called twice.
What about modifying the gpiolib code to handle that? I think that
sounds like a better idea than cover ing that case in the chip code...
Thanks!
/ magnus
next prev parent reply other threads:[~2008-09-27 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-24 22:08 David Brownell
2008-09-27 15:00 ` Magnus Damm [this message]
2008-09-27 18:29 ` David Brownell
2008-09-29 3:48 ` Magnus Damm
2008-09-29 17:21 ` David Brownell
2008-10-06 4:57 ` David Brownell
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=aec7e5c30809270800y7a4b59eem8af480d5899a791a@mail.gmail.com \
--to=magnus.damm@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david-b@pacbell.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®