2022-09-08 05:49:24

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 2/4] gpiolib: of: make Freescale SPI quirk similar to all others

There is no need for of_find_spi_cs_gpio() to be different from other
quirks: the only variant of property actually used in DTS is "gpios"
(plural) so we can use of_get_named_gpiod_flags() instead of recursing
into of_find_gpio() again.

This will allow us consolidate quirk handling down the road.

Signed-off-by: Dmitry Torokhov <[email protected]>
---
drivers/gpio/gpiolib-of.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index c08564948bf9..30b89b694530 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -407,7 +407,7 @@ static struct gpio_desc *of_find_spi_gpio(struct device *dev,
static struct gpio_desc *of_find_spi_cs_gpio(struct device *dev,
const char *con_id,
unsigned int idx,
- unsigned long *flags)
+ enum of_gpio_flags *of_flags)
{
const struct device_node *np = dev->of_node;

@@ -428,7 +428,7 @@ static struct gpio_desc *of_find_spi_cs_gpio(struct device *dev,
* uses just "gpios" so translate to that when "cs-gpios" is
* requested.
*/
- return of_find_gpio(dev, NULL, idx, flags);
+ return of_get_named_gpiod_flags(dev->of_node, "gpios", idx, of_flags);
}

/*
@@ -527,12 +527,8 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
desc = of_find_spi_gpio(dev, con_id, idx, &of_flags);
}

- if (gpiod_not_found(desc)) {
- /* This quirk looks up flags and all */
- desc = of_find_spi_cs_gpio(dev, con_id, idx, flags);
- if (!IS_ERR(desc))
- return desc;
- }
+ if (gpiod_not_found(desc))
+ desc = of_find_spi_cs_gpio(dev, con_id, idx, &of_flags);

if (gpiod_not_found(desc)) {
/* Special handling for regulator GPIOs if used */
--
2.37.2.789.g6183377224-goog


2022-09-08 13:02:23

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 2/4] gpiolib: of: make Freescale SPI quirk similar to all others

On Thu, Sep 8, 2022 at 7:39 AM Dmitry Torokhov
<[email protected]> wrote:

> There is no need for of_find_spi_cs_gpio() to be different from other
> quirks: the only variant of property actually used in DTS is "gpios"
> (plural) so we can use of_get_named_gpiod_flags() instead of recursing
> into of_find_gpio() again.
>
> This will allow us consolidate quirk handling down the road.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij