From: Daniel Mack <zonque@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org,
Grant Likely <grant.likely@secretlab.ca>,
Linus Walleij <linus.walleij@stericsson.com>
Subject: Re: [PATCH] gpiolib: fix chip->base handling in of_gpio_simple_xlate()
Date: Tue, 24 Jul 2012 17:22:12 +0200 [thread overview]
Message-ID: <500EBDA4.6020104@gmail.com> (raw)
In-Reply-To: <201207241408.44168.arnd@arndb.de>
On 24.07.2012 16:08, Arnd Bergmann wrote:
> On Tuesday 24 July 2012, Daniel Mack wrote:
>>>>> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
>>>>> index d18068a..51bc232 100644
>>>>> --- a/drivers/gpio/gpiolib-of.c
>>>>> +++ b/drivers/gpio/gpiolib-of.c
>>>>> @@ -147,13 +147,13 @@ int of_gpio_simple_xlate(struct gpio_chip *gc,
>>>>> if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
>>>>> return -EINVAL;
>>>>>
>>>>> - if (gpiospec->args[0] >= gc->ngpio)
>>>>> + if (gpiospec->args[0] >= gc->ngpio + gc->base)
>>>>> return -EINVAL;
>>>>>
>>>>> if (flags)
>>>>> *flags = gpiospec->args[1];
>>>>>
>>>>> - return gpiospec->args[0];
>>>>> + return gpiospec->args[0] - gc->base;
>>>>> }
>>>>> EXPORT_SYMBOL(of_gpio_simple_xlate);
>>>
>>> Where would that gc->base come from?
>>
>> It is set up when the chips are initialized. Let's put it that way: why
>> would we have this ->base if it is practically unusable in devicetree
>> environments?
>
> The base gets used to put the gpiochip into the Linux gpio number space,
> which is not necessarily the same as the number space used in the device
> tree. You can dynamically add other gpio controllers that would get
> some arbitrary base assigned at runtime, so you cannot subtract that
> base from the hardware number to get a local one in the common code.
>
> I fear you will have to provide your own xlate function for pxa if
> you want to use this numbering. Something like this:?
I did my own xlate function in the first place, but then I thought it
could be made working in a more general way. But your explanation makes
sense, so I will add something that is based on your sniplet.
Thanks,
Daniel
prev parent reply other threads:[~2012-07-24 15:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-22 17:10 [PATCH] gpiolib: fix chip->base handling in of_gpio_simple_xlate() Daniel Mack
2012-07-23 14:43 ` Daniel Mack
2012-07-24 12:56 ` Arnd Bergmann
2012-07-24 13:04 ` Daniel Mack
2012-07-24 14:08 ` Arnd Bergmann
2012-07-24 15:22 ` Daniel Mack [this message]
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=500EBDA4.6020104@gmail.com \
--to=zonque@gmail.com \
--cc=arnd@arndb.de \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@stericsson.com \
--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;
as well as URLs for NNTP newsgroup(s).