From: Guenter Roeck <linux@roeck-us.net>
To: Alexandre Courbot <gnurou@gmail.com>
Cc: Alexandre Courbot <acourbot@nvidia.com>,
Linus Walleij <linus.walleij@linaro.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/5] gpio: make gpiochip_get_desc() gpiolib-private
Date: Tue, 22 Jul 2014 20:47:38 -0700 [thread overview]
Message-ID: <53CF305A.6080007@roeck-us.net> (raw)
In-Reply-To: <CAAVeFuJAudOY-s3x38sv13SNo8zfofLWKOKBhKQPYAm1fAj4kw@mail.gmail.com>
On 07/22/2014 08:10 PM, Alexandre Courbot wrote:
> On Wed, Jul 23, 2014 at 5:17 AM, Guenter Roeck <linux@roeck-us.net> wrote:
>> On Tue, Jul 22, 2014 at 04:17:41PM +0900, Alexandre Courbot wrote:
>>> As GPIO descriptors are not going to remain unique anymore, having this
>>> function public is not safe. Restrain its use to gpiolib since we have
>>> no user outside of it.
>>>
>> If I implement a gpio chip driver built as module, and I want to use
>> gpiochip_request_own_desc(), how am I supposed to get desc ?
>>
>> I understand that there is still gpio_to_desc(), but I would have thought
>> that
>> desc = gpiochip_get_desc(chip, pin);
>> would be better than
>> desc = gpio_to_desc(chip->base + pin);
>>
>> Not that it makes much of a difference for me, just asking.
>
> Actually I was thinking of changing the prototype of
> gpiochip_request_own_desc(), and your comment definitely strenghtens
> that idea. gpiochip functions should not work with descriptors,
> especially since we are going to switch to a multiple-consumer scheme
> where there won't be any canonical descriptor anymore. Thus, how about
> turning gpiochip_request_own_desc() into this:
>
> struct gpio_desc *
> gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, const char *label);
>
> which would basically do both the gpiochip_get_desc() and former
> gpiochip_request_own_desc() in one call. I think it should satisfy
> everybody and removes the need to have gpiochip_get_desc() (a not very
> useful function by itself) exposed out of gpiolib.
>
> I will send a patch taking care of this if you agree that makes sense.
>
I think you also plan to remove the capability to retrieve the chip
pointer, don't you ? If so, I won't be able to use the function from
the pca953x platform init function, since I won't be able to get the
pointer to the gpio chip. Even if you don't remove gpiod_to_chip(),
things would become a bit messy, since I would first have to convert
a pin to a desc and then to the chip pointer. Anyway, that change
would mean that exporting gpiochip_request_own_desc or its replacement
won't solve one of the problems addressed by my patch anymore, leaving
me more or less in the dark :-(.
I was thinking about implementing a separate platform driver which
would enable me to auto-export (or initialize, if needed) gpio pins
from arbitrary gpio drivers to user space. I could make this work
with both devicetree data and platform data. Sure, that driver
would not have a chance to get accepted upstream, since it would use
devicetree data to, in a sense, configure the system, but on the
upside it would be independent of gpio API changes, and it would
work for _all_ gpio chips, not just for the ones with gpio driver
support. Unfortunately this approach doesn't really work either,
since exported pin names need to be configured with the chip driver,
and can not be selected afterwards when a pin is actually exported.
On the other side, would you agree to adding something like
gpiod_export_name(), which would export a gpio pin with given name,
not using the default or chip->names ? That might help solving
at least some of my problems, and I would no longer depend on
gpiochip_request_own_desc or any of the related functions.
For reference, I currently need the ability to auto-export
gpio pins to user space for pca953x, ich, and for various
to-be-published gpio drivers used by my employer.
Thanks,
Guenter
next prev parent reply other threads:[~2014-07-23 3:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 7:17 [PATCH 0/5] gpio: a few cleanup patches Alexandre Courbot
2014-07-22 7:17 ` [PATCH 1/5] gpio: remove export of private of_get_named_gpio_flags() Alexandre Courbot
2014-07-23 15:36 ` Linus Walleij
2014-07-22 7:17 ` [PATCH 2/5] gpio: simplify gpiochip_export() Alexandre Courbot
2014-07-23 15:38 ` Linus Walleij
2014-07-22 7:17 ` [PATCH 3/5] gpio: make gpiochip_get_desc() gpiolib-private Alexandre Courbot
2014-07-22 20:17 ` Guenter Roeck
2014-07-23 3:10 ` Alexandre Courbot
2014-07-23 3:47 ` Guenter Roeck [this message]
2014-07-23 5:39 ` Alexandre Courbot
2014-07-23 6:21 ` Guenter Roeck
2014-07-23 14:48 ` Alexandre Courbot
2014-07-23 15:41 ` Linus Walleij
2014-07-22 7:17 ` [PATCH 4/5] gpio: remove gpiod_lock/unlock_as_irq() Alexandre Courbot
2014-07-23 15:45 ` Linus Walleij
2014-07-22 7:17 ` [PATCH 5/5] gpio: move gpio_ensure_requested() into legacy C file Alexandre Courbot
2014-07-22 8:30 ` Varka Bhadram
2014-07-23 15:48 ` Linus Walleij
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=53CF305A.6080007@roeck-us.net \
--to=linux@roeck-us.net \
--cc=acourbot@nvidia.com \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--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