Re: [PATCH] gpiolib: fix chip->base handling in of_gpio_simple_xlate()
From: Daniel Mack
Date: Tue Jul 24 2012 - 11:22:11 EST
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/