lkml.org 
[lkml]   [2012]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] gpiolib: fix chip->base handling in of_gpio_simple_xlate()
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


\
 
 \ /
  Last update: 2012-07-24 18:01    [W:0.090 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site