From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Alexandre Courbot <gnurou@gmail.com>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
rjw@rjwysocki.net, Linus Walleij <linus.walleij@linaro.org>,
Grant Likely <grant.likely@secretlab.ca>,
Mathias Nyman <mathias.nyman@linux.intel.com>,
Alexandre Courbot <acourbot@nvidia.com>,
Rob Landley <rob@landley.net>,
linux-acpi@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/5] gpiolib / ACPI: convert to gpiod interfaces
Date: Wed, 9 Oct 2013 10:58:30 +0300 [thread overview]
Message-ID: <20131009075830.GS3521@intel.com> (raw)
In-Reply-To: <CAAVeFu+_EUCs+70+WzCq530JUesrHzULi34mCf7-pRVVP1WV7g@mail.gmail.com>
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@linux.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-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Alexandre Courbot <gnurou@gmail.com>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
rjw@rjwysocki.net, Linus Walleij <linus.walleij@linaro.org>,
Grant Likely <grant.likely@secretlab.ca>,
Mathias Nyman <mathias.nyman@linux.intel.com>,
Alexandre Courbot <acourbot@nvidia.com>,
Rob Landley <rob@landley.net>,
linux-acpi@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/5] gpiolib / ACPI: convert to gpiod interfaces
Date: Wed, 9 Oct 2013 10:58:30 +0300 [thread overview]
Message-ID: <20131009075830.GS3521@intel.com> (raw)
In-Reply-To: <CAAVeFu+_EUCs+70+WzCq530JUesrHzULi34mCf7-pRVVP1WV7g@mail.gmail.com>
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@linux.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?
next prev parent reply other threads:[~2013-10-09 7:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-01 14:58 [PATCH 0/5] gpiolib: convert ACPI GPIO helpers to gpiod_ interfaces Mika Westerberg
2013-10-01 14:58 ` [PATCH 1/5] gpiolib / ACPI: move acpi_gpiochip_free_interrupts next to the request function Mika Westerberg
2013-10-11 10:52 ` Linus Walleij
2013-10-01 14:58 ` [PATCH 2/5] gpiolib / ACPI: convert to gpiod interfaces Mika Westerberg
2013-10-08 4:54 ` Alexandre Courbot
2013-10-08 8:45 ` Mika Westerberg
2013-10-08 8:45 ` Mika Westerberg
2013-10-08 10:36 ` Mika Westerberg
2013-10-08 16:26 ` Alexandre Courbot
2013-10-09 8:01 ` Mika Westerberg
2013-10-08 16:24 ` Alexandre Courbot
2013-10-08 16:24 ` Alexandre Courbot
2013-10-09 7:58 ` Mika Westerberg [this message]
2013-10-09 7:58 ` Mika Westerberg
2013-10-09 16:36 ` Alexandre Courbot
2013-10-09 16:36 ` Alexandre Courbot
2013-10-01 14:58 ` [PATCH 3/5] gpiolib / ACPI: add ACPI support for gpiod_get_index() Mika Westerberg
2013-10-01 14:58 ` [PATCH 4/5] gpiolib / ACPI: allow passing GPIOF_ACTIVE_LOW for GpioInt resources Mika Westerberg
2013-10-01 14:58 ` [PATCH 5/5] gpiolib / ACPI: document the GPIO descriptor based interface Mika Westerberg
2013-10-07 12:18 ` [PATCH 0/5] gpiolib: convert ACPI GPIO helpers to gpiod_ interfaces Rafael J. Wysocki
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=20131009075830.GS3521@intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=acourbot@nvidia.com \
--cc=gnurou@gmail.com \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
--cc=rjw@rjwysocki.net \
--cc=rob@landley.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.