* [PATCH] gpiolib: use platform GPIO mappings as fallback
@ 2013-11-23 10:34 Alexandre Courbot
2013-11-29 9:29 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Courbot @ 2013-11-23 10:34 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-kernel, Alexandre Courbot
For platforms that use device tree or ACPI as the standard way to look
GPIOs up, allow the platform-defined GPIO mappings to be used as a
fallback. This may be useful for platforms that need extra GPIOs mappings
not defined by the firmware.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpio/gpiolib.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 86caf17..4edd68c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2417,7 +2417,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
const char *con_id,
unsigned int idx)
{
- struct gpio_desc *desc;
+ struct gpio_desc *desc = NULL;
int status;
enum gpio_lookup_flags flags = 0;
@@ -2430,9 +2430,19 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
} else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) {
dev_dbg(dev, "using ACPI for GPIO lookup\n");
desc = acpi_find_gpio(dev, con_id, idx, &flags);
- } else {
+ }
+
+ /*
+ * Either we are not using DT or ACPI, or their lookup did not return
+ * a result. In that case, use platform lookup as a fallback.
+ */
+ if (!desc || IS_ERR(desc)) {
+ struct gpio_desc *pdesc;
dev_dbg(dev, "using lookup tables for GPIO lookup");
- desc = gpiod_find(dev, con_id, idx, &flags);
+ pdesc = gpiod_find(dev, con_id, idx, &flags);
+ /* If used as fallback, do not replace the previous error */
+ if (!IS_ERR(pdesc) || !desc)
+ desc = pdesc;
}
if (IS_ERR(desc)) {
--
1.8.4.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] gpiolib: use platform GPIO mappings as fallback
2013-11-23 10:34 [PATCH] gpiolib: use platform GPIO mappings as fallback Alexandre Courbot
@ 2013-11-29 9:29 ` Linus Walleij
2013-11-29 9:35 ` Alex Courbot
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2013-11-29 9:29 UTC (permalink / raw)
To: Alexandre Courbot
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
On Sat, Nov 23, 2013 at 11:34 AM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> For platforms that use device tree or ACPI as the standard way to look
> GPIOs up, allow the platform-defined GPIO mappings to be used as a
> fallback. This may be useful for platforms that need extra GPIOs mappings
> not defined by the firmware.
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Applied for fixes. I was considering applying it for the next
kernel but it depends on the former patches and we should
expect a bit of extra fuzz now with the new API.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpiolib: use platform GPIO mappings as fallback
2013-11-29 9:29 ` Linus Walleij
@ 2013-11-29 9:35 ` Alex Courbot
0 siblings, 0 replies; 3+ messages in thread
From: Alex Courbot @ 2013-11-29 9:35 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
On 11/29/2013 06:29 PM, Linus Walleij wrote:
> On Sat, Nov 23, 2013 at 11:34 AM, Alexandre Courbot <acourbot@nvidia.com> wrote:
>
>> For platforms that use device tree or ACPI as the standard way to look
>> GPIOs up, allow the platform-defined GPIO mappings to be used as a
>> fallback. This may be useful for platforms that need extra GPIOs mappings
>> not defined by the firmware.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>
> Applied for fixes. I was considering applying it for the next
> kernel but it depends on the former patches and we should
> expect a bit of extra fuzz now with the new API.
Thanks - I'd rather have all the problems coming in a row than
incrementally as we introduce potentially incompatible changes.
Alex.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-29 9:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-23 10:34 [PATCH] gpiolib: use platform GPIO mappings as fallback Alexandre Courbot
2013-11-29 9:29 ` Linus Walleij
2013-11-29 9:35 ` Alex Courbot
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).