Re: [PATCH v3 2/2] gpio: add gpio-line-mux driver
From: Thomas Richard
Date: Wed Nov 05 2025 - 03:51:20 EST
Hi Jonas,
On 11/4/25 10:00 PM, Jonas Jelonek wrote:
> Add a new driver which provides a 1-to-many mapping for a single real
> GPIO using a multiplexer. Each virtual GPIO corresponds to a multiplexer
> state which, if set for the multiplexer, connects the real GPIO to the
> corresponding virtual GPIO.
[...]
> +
> +struct gpio_lmux {
> + struct gpio_chip gc;
> + struct mux_control *mux;
> + 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))
I think you don't need this. A mutex guard is already defined in the
mutex header file [1].
So you just have to call:
guard(mutex)(&glm->lock);
[1]
https://elixir.bootlin.com/linux/v6.17.7/source/include/linux/mutex.h#L228
> +
> +static int gpio_lmux_gpio_get(struct gpio_chip *gc, unsigned int offset)
> +{
> + struct gpio_lmux *glm = (struct gpio_lmux *)gpiochip_get_data(gc);
useless cast
Best Regards,
Thomas