lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aec7e5c30809270800y7a4b59eem8af480d5899a791a@mail.gmail.com>
Date:	Sun, 28 Sep 2008 00:00:24 +0900
From:	"Magnus Damm" <magnus.damm@...il.com>
To:	"David Brownell" <david-b@...bell.net>
Cc:	"Andrew Morton" <akpm@...ux-foundation.org>,
	lkml <linux-kernel@...r.kernel.org>
Subject: Re: [patch 2.6.27-rc7] gpiolib: request/free hooks

Hi David,

On Thu, Sep 25, 2008 at 7:08 AM, David Brownell <david-b@...bell.net> wrote:
> From: David Brownell <dbrownell@...rs.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@...rs.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
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ