RE: [PATCH 2/3] ASoC: codec: wcd938x: Convert to GPIO descriptors

From: Peng Fan
Date: Mon Mar 24 2025 - 04:35:16 EST


> Subject: Re: [PATCH 2/3] ASoC: codec: wcd938x: Convert to GPIO
> descriptors
>
> On Mon, Mar 24, 2025 at 9:09 AM Peng Fan <peng.fan@xxxxxxx>
> wrote:
>
> > ok, then the only suspecting point is
> > wcd938x->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_ASIS);
> >
> > I may need to use GPIOD_OUT_LOW to configure it to output as set
> raw
> > set value as 1.
>
> I think there may be a bug in gpiod_configure_flags() in gpiolib.c:
>
> /* Process flags */
> if (dflags & GPIOD_FLAGS_BIT_DIR_OUT)
> ret = gpiod_direction_output_nonotify(desc,
> !!(dflags & GPIOD_FLAGS_BIT_DIR_VAL));
> else
> ret = gpiod_direction_input_nonotify(desc);
>
> Shouldn't this be:
>
> if (dflags & GPIOD_FLAGS_BIT_DIR_OUT)
> ret = gpiod_direction_output_nonotify(desc,
> !!(dflags & GPIOD_FLAGS_BIT_DIR_VAL));
> else if (dflags & GPIOD_FLAGS_BIT_DIR_SET)
> ret = gpiod_direction_input_nonotify(desc);

Using GPIO_ASIS should not change direction.
This change makes sense.

>
> ?
>
> As it looks, the line will be set into input mode unless explicitly
> requested as output...
>
> However this means the patch also has another bug: you need to either:
>
> 1. Specify GPIO_OUT_LOW when requesting it or 2. Explicitly call
> gpiod_direction_out() before setting the value.

1 is better before the gpiolib bug got fixed. Then no need change
direction twice.
2 is better aligned with current driver.

There is no rush, so I could use 2 if you'd fix the gpiolib.

BTW, could I still keep your R-b in my V2?

Thanks,
Peng.

>
> Yours,
> Linus Walleij