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

Linus Walleij linus.walleij at linaro.org
Fri Aug 25 04:45:20 PDT 2023


On Fri, Aug 25, 2023 at 11:53 AM 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>
> Suggested-by: Linus Walleij <linus.walleij at linaro.org>

Reviewed-by: Linus Walleij <linus.walleij at linaro.org>

> +#if IS_ENABLED(CONFIG_MMC_ATMELMCI)
> +       /*
> +        * The Atmel HSMCI has compatible property in the parent node and
> +        * gpio property in a child node
> +        */
> +       if (of_device_is_compatible(np->parent, "atmel,hsmci")) {
> +               np_compat = np->parent;
> +               np_propname = np;
> +       }
> +#endif

You don't need to use the preprocessor actually, what I did in my
example works:

if (IS_ENABLED()... && of_device_is_compatible()...) {
...
}

If the first expression in the if() clause is constant false, the compiler
will optimize out the entire if()-clause. At least the compilers we care
about.

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list