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]
Date:	Wed, 9 Oct 2013 10:58:30 +0300
From:	Mika Westerberg <mika.westerberg@...ux.intel.com>
To:	Alexandre Courbot <gnurou@...il.com>
Cc:	"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	rjw@...ysocki.net, Linus Walleij <linus.walleij@...aro.org>,
	Grant Likely <grant.likely@...retlab.ca>,
	Mathias Nyman <mathias.nyman@...ux.intel.com>,
	Alexandre Courbot <acourbot@...dia.com>,
	Rob Landley <rob@...dley.net>, linux-acpi@...r.kernel.org,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/5] gpiolib / ACPI: convert to gpiod interfaces

On Tue, Oct 08, 2013 at 09:24:50AM -0700, Alexandre Courbot wrote:
> On Tue, Oct 8, 2013 at 1:45 AM, Mika Westerberg
> <mika.westerberg@...ux.intel.com> wrote:
> > On Mon, Oct 07, 2013 at 09:54:13PM -0700, Alexandre Courbot wrote:
> >> > +struct gpio_desc *acpi_get_gpiod(char *path, int pin)
> >> >  {
> >> >         struct gpio_chip *chip;
> >> >         acpi_handle handle;
> >> > @@ -48,18 +49,15 @@ int acpi_get_gpio(char *path, int pin)
> >> >
> >> >         status = acpi_get_handle(NULL, path, &handle);
> >> >         if (ACPI_FAILURE(status))
> >> > -               return -ENODEV;
> >> > +               return ERR_PTR(-ENODEV);
> >> >
> >> >         chip = gpiochip_find(handle, acpi_gpiochip_find);
> >> >         if (!chip)
> >> > -               return -ENODEV;
> >> > +               return ERR_PTR(-ENODEV);
> >> >
> >> > -       if (!gpio_is_valid(chip->base + pin))
> >> > -               return -EINVAL;
> >> > -
> >> > -       return chip->base + pin;
> >> > +       return gpio_to_desc(chip->base + pin);
> >>
> >> I think you want to avoid using gpio_to_desc(). It is just a
> >> convenience function provided to ease the transition for consumers
> >> that still need to rely on GPIO numbers for some reason. The same
> >> applies to desc_to_gpio(), although the usage you are making of it
> >> (implemented fallbacks for the integer space) is the one that is
> >> intended.
> >>
> >> The last line could be changed to "return &chip->desc[pin];" after
> >> checking that 0 <= pin <= chip->ngpio.
> >
> > I tried that but it doesn't compile anymore :-(
> >
> > drivers/gpio/gpiolib-acpi.c: In function ‘acpi_get_gpiod’:
> > drivers/gpio/gpiolib-acpi.c:61:2: error: invalid use of undefined type ‘struct gpio_desc’
> > drivers/gpio/gpiolib-acpi.c:61:20: error: dereferencing pointer to incomplete type
> 
> Ah right, there is no way to know the size of a gpio_desc from here...
> Maybe I should make a gpiochip_get_desc(index) function accessible to
> drivers only that takes care of this. Another possibility would be to
> move this function into gpiolib.c but there are probably too many
> dependencies with ACPI for that.
> 
> In the long term I would like to see gpio_to_desc()/desc_to_gpio()
> disappear from the consumer interface as they allow unsafe use of GPIO
> descriptors.
> 
> > The DT version also uses gpio_to_desc().
> 
> That seems to speak in favor of that gpiochip_get_desc() function I
> talked about earlier.

OK, I can convert the ACPI code to use that once such function exists. I
the meanwhile, can I use gpio_to_desc() in the next revision of the
patches?
--
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