diff mbox series

[01/11] gpiolib: of: add a fallback for wlf,reset GPIO name

Message ID 20190911075215.78047-2-dmitry.torokhov@gmail.com
State New
Headers show
Series Add support for software nodes to gpiolib | expand

Commit Message

Dmitry Torokhov Sept. 11, 2019, 7:52 a.m. UTC
The old Arizona binding did not use -gpio or -gpios suffix, so
devm_gpiod_get() does not work for it. As it is the one of a few users
of devm_gpiod_get_from_of_node() API that I want to remove, I'd rather
have a small quirk in the gpiolib OF handler, and switch Arizona
driver to devm_gpiod_get().

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

 drivers/gpio/gpiolib-of.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Linus Walleij Sept. 12, 2019, 9:30 a.m. UTC | #1
On Wed, Sep 11, 2019 at 8:52 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> The old Arizona binding did not use -gpio or -gpios suffix, so
> devm_gpiod_get() does not work for it. As it is the one of a few users
> of devm_gpiod_get_from_of_node() API that I want to remove, I'd rather
> have a small quirk in the gpiolib OF handler, and switch Arizona
> driver to devm_gpiod_get().
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Patch applied, good to have this in and it is completely in line
with my idea to handle all these quirks inside the gpiolib-of.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index b45b39c48a34..8b773f7d7724 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -438,6 +438,19 @@  static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char *
 	return desc;
 }
 
+static struct gpio_desc *of_find_arizona_gpio(struct device *dev,
+					      const char *con_id,
+					      enum of_gpio_flags *of_flags)
+{
+	if (!IS_ENABLED(CONFIG_MFD_ARIZONA))
+		return ERR_PTR(-ENOENT);
+
+	if (!con_id || strcmp(con_id, "wlf,reset"))
+		return ERR_PTR(-ENOENT);
+
+	return of_get_named_gpiod_flags(dev->of_node, con_id, 0, of_flags);
+}
+
 struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
 			       unsigned int idx, unsigned long *flags)
 {
@@ -479,6 +492,9 @@  struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
 		desc = of_find_regulator_gpio(dev, con_id, &of_flags);
 	}
 
+	if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT)
+		desc = of_find_arizona_gpio(dev, con_id, &of_flags);
+
 	if (IS_ERR(desc))
 		return desc;