From: <Balamanikandan.Gunasundar@microchip.com>
To: <linus.walleij@linaro.org>
Cc: <dmitry.torokhov@gmail.com>, <ulf.hansson@linaro.org>,
<linux-kernel@vger.kernel.org>, <linux-mmc@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<Ludovic.Desroches@microchip.com>, <Nicolas.Ferre@microchip.com>,
<alexandre.belloni@bootlin.com>, <Hari.PrasathGE@microchip.com>,
<Balamanikandan.Gunasundar@microchip.com>
Subject: Re: [PATCH v5 3/3] mmc: atmel-mci: Move card detect gpio polarity quirk to gpiolib
Date: Thu, 24 Aug 2023 06:39:06 +0000 [thread overview]
Message-ID: <63156971-6f3d-4023-90d9-98adc000a32e@microchip.com> (raw)
In-Reply-To: <CACRpkda2gJkj6_25rnLUHNaLC3_kcSbCF+y6RRvbnUsju-iJYg@mail.gmail.com>
Hi Linus,
Thanks for reviewing the patch.
On 23/08/23 6:11 pm, Linus Walleij wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Hi Balamanikandan,
>
> thanks for your patch!
>
> On Wed, Aug 23, 2023 at 12:40 PM Balamanikandan Gunasundar
> <balamanikandan.gunasundar@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@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") &&
The only difference above is "np->parent" while the existing code uses
"np". This is because the compatible string is defined in the parent
node here while the others have it in the same node.
mmc0: mmc@f0000000 {
compatible = "atmel,hsmci";
...
slot@0 {
cd-gpios = <&pioE 0 GPIO_ACTIVE_LOW>;
cd-inverted;
}
}
>> + !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?
Yes! I attempted to do so. But as explained above in this particular
case, of_device_is_compatible(np->parent, ..) should be called. Adding a
condition check here looked clumsy.
>
> 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
> (...)
>
I think with the above entry I can also add a check like ...
if (np->parent) {
if (of_device_is_compatible(np->parent, "atmel,hsmci") &&
!strcmp(propname, gpios[i].gpio_propname))
active_high = of_property_read_bool();
}
Please let me know your thoughts.
Thanks,
Balamanikandan
>
> Yours,
> Linus Walleij
next prev parent reply other threads:[~2023-08-24 6:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 10:40 [PATCH v5 0/3] mmc: atmel-mci: Convert to gpio descriptors Balamanikandan Gunasundar
2023-08-23 10:40 ` [PATCH v5 1/3] " Balamanikandan Gunasundar
2023-08-23 10:40 ` [PATCH v5 2/3] mmc: atmel-mci: move atmel MCI header file Balamanikandan Gunasundar
2023-08-23 10:40 ` [PATCH v5 3/3] mmc: atmel-mci: Move card detect gpio polarity quirk to gpiolib Balamanikandan Gunasundar
2023-08-23 12:41 ` Linus Walleij
2023-08-24 6:39 ` Balamanikandan.Gunasundar [this message]
2023-08-24 8:33 ` Linus Walleij
2023-08-24 10:33 ` Balamanikandan.Gunasundar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=63156971-6f3d-4023-90d9-98adc000a32e@microchip.com \
--to=balamanikandan.gunasundar@microchip.com \
--cc=Hari.PrasathGE@microchip.com \
--cc=Ludovic.Desroches@microchip.com \
--cc=Nicolas.Ferre@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox