Re: [PATCH v3 1/2] mmc: atmel-mci: Convert to gpio descriptors
From: Linus Walleij
Date: Wed Dec 28 2022 - 19:23:57 EST
Hi Balamanikandan,
thanks for your patch!
On Mon, Dec 26, 2022 at 8:39 AM Balamanikandan Gunasundar
<balamanikandan.gunasundar@xxxxxxxxxxxxx> wrote:
> Replace the legacy GPIO APIs with gpio descriptor consumer interface.
>
> To maintain backward compatibility, we rely on the "cd-inverted"
> property to manage the invertion flag instead of GPIO property.
>
> Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@xxxxxxxxxxxxx>
Overall this looks really nice! I thought about converting this driver
but was a bit afraid of doing mistakes since it was a bit elaborate.
Nice that you use fwnode accessors!
Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
Improvement to consider (can also be a separate patch):
> + if (slot->detect_pin) {
> + present = !(gpiod_get_raw_value(slot->detect_pin) ^
> slot->detect_is_active_high);
Normally we contain all this active low/high mess in mmc_of_parse(),
but I guess this doesn't work here because the of node is different
from the device :P
Since the code says *explicitly* "active high" not "inverted" as the
core code parses it, could you try just push this to gpiolib like
we usually do, by deleting the detect_is_active_high stuff and
just apply a patch like this?
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 4fff7258ee41..5979c9a75cf9 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -199,7 +199,9 @@ static void of_gpio_set_polarity_by_property(const
struct device_node *np,
{ "fsl,imx8mm-pcie", "reset-gpio", "reset-gpio-active-high" },
{ "fsl,imx8mp-pcie", "reset-gpio", "reset-gpio-active-high" },
#endif
-
+#if IS_ENABLED(CONFIG_MMC_ATMELMCI)
+ { "atmel,hsmci", "cd-gpios", "cd-inverted" },
+#endif
/*
* The regulator GPIO handles are specified such that the
* presence or absence of "enable-active-high" solely controls
(It's fine to include in your MMC patch if some GPIO maintainer like
me ACK it.)
Yours,
Linus Walleij