[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <59b5eac8-3380-4fb4-a13d-9e4b32b403c4@gmail.com>
Date: Tue, 4 Nov 2025 15:57:15 +0100
From: Jonas Jelonek <jelonek.jonas@...il.com>
To: Thomas Richard <thomas.richard@...tlin.com>,
Linus Walleij <linus.walleij@...aro.org>, Bartosz Golaszewski
<brgl@...ev.pl>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Peter Rosin <peda@...ntia.se>,
Geert Uytterhoeven <geert+renesas@...der.be>
Cc: linux-gpio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] gpio: add gpio-line-mux driver
Hi Thomas,
On 28.10.25 10:45, Thomas Richard wrote:
> On 10/27/25 12:17 AM, Jonas Jelonek wrote:
>> +
>> + struct mutex lock;
>> +
>> + struct gpio_desc *shared_gpio;
>> + /* dynamically sized, must be last */
>> + unsigned int gpio_mux_states[];
>> +};
>> +
>> +DEFINE_GUARD(gpio_lmux, struct gpio_lmux *, mutex_lock(&_T->lock), mutex_unlock(&_T->lock))
>> +
>> +static int gpio_lmux_gpio_get(struct gpio_chip *gc, unsigned int offset)
>> +{
>> + struct gpio_lmux *glm = (struct gpio_lmux *)gpiochip_get_data(gc);
>> + int ret;
>> +
>> + if (offset > gc->ngpio)
>> + return -EINVAL;
>> +
>> + guard(gpio_lmux)(glm);
>> +
>> + ret = mux_control_select(glm->mux, glm->gpio_mux_states[offset]);
>> + if (ret < 0)
>> + return ret;
>> +
>> + ret = gpiod_get_raw_value_cansleep(glm->shared_gpio);
> Why ignoring ACTIVE_LOW status ?
I think this would be rather error-prone and doesn't make sense to me. The
consumer of this driver should decide about whether it uses ACTIVE_HIGH or
ACTIVE_LOW for each one of the virtual GPIOs separately. This should then be
applied as if this was a real GPIO. Following the ACTIVE_* that is given in
the 'shared-gpio' property then would interfere again.
> [...]
>
Thanks for all the suggested simplifications, I'll incorporate them.
> The advantage of the forwarder is that it handles if the shared GPIO is
> sleeping or not.
> But I think the forwarder shall have ngpio, not 1. You will have to add
> ngpio times the same GPIO desc. Also unsupported operations shall be unset.
> So I don't really know if it shall be used in this case.
I agree. As Peter mentioned, I need to use "can_sleep" anyway because of the mux.
So there's not really an argument left to use the forwarder.
> Best Regards,
>
> Thomas
Best regards,
Jonas
Powered by blists - more mailing lists