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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Balamanikandan,

thanks for your patch!

On Wed, Aug 23, 2023 at 12:40 PM 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>
(...)
>  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




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux