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

From: Linus Walleij
Date: Fri Aug 25 2023 - 07:46:43 EST


On Fri, Aug 25, 2023 at 11:53 AM Balamanikandan Gunasundar
<balamanikandan.gunasundar@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx>
> Suggested-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

> +#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