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

From: Linus Walleij
Date: Mon Mar 24 2025 - 04:24:11 EST


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);

?

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.

Yours,
Linus Walleij