[PATCH v5 3/3] mmc: atmel-mci: Move card detect gpio polarity quirk to gpiolib

Linus Walleij linus.walleij at linaro.org
Wed Aug 23 05:41:14 PDT 2023


Hi Balamanikandan,

thanks for your patch!

On Wed, Aug 23, 2023 at 12:40 PM Balamanikandan Gunasundar
<balamanikandan.gunasundar at microchip.com> wrote:

> The polarity of the card detection gpio is handled by the "cd-inverted"
> property in the device tree. Move this inversion logic to gpiolib to avoid
> reading the gpio raw value.
>
> Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar at microchip.com>
(...)
>  drivers/gpio/gpiolib-of.c    |  7 +++++++

Patching here is the right approach!

> +#if IS_ENABLED(CONFIG_MMC_ATMELMCI)
> +       if (of_device_is_compatible(np->parent, "atmel,hsmci") &&
> +           !strcmp(propname, "cd-gpios")) {
> +               active_high = of_property_read_bool(np, "cd-inverted");
> +               of_gpio_quirk_polarity(np, active_high, flags);
> +       }
> +#endif
>         for (i = 0; i < ARRAY_SIZE(gpios); i++) {
>                 if (of_device_is_compatible(np, gpios[i].compatible) &&
>                     !strcmp(propname, gpios[i].gpio_propname)) {

This duplicates the code right below. Can't you just add an entry to the
existing gpios[] array?

I would imagine:

    static const struct {
        const char *compatible;
        const char *gpio_propname;
        const char *polarity_propname;
    } gpios[] = {
#if IS_ENABLED(CONFIG_MMC_ATMELMCI)
        { "atmel,hsmci", "cd-gpios", "cd-inverted" },
#endif
(...)


Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list