Re: [PATCH v7 2/2] gpio: add gpio-line-mux driver

From: Dan Carpenter

Date: Wed Jan 07 2026 - 03:40:13 EST


On Sat, Dec 27, 2025 at 06:01:34PM +0000, Jonas Jelonek wrote:
> +struct gpio_lmux {
> + struct gpio_chip gc;
> + struct mux_control *mux;
> + struct gpio_desc *muxed_gpio;
> +
> + u32 num_gpio_mux_states;
> + unsigned int gpio_mux_states[] __counted_by(num_gpio_mux_states);
> +};
> +
> +static int gpio_lmux_gpio_get(struct gpio_chip *gc, unsigned int offset)
> +{
> + struct gpio_lmux *glm = gpiochip_get_data(gc);
> + int ret;
> +
> + if (offset > gc->ngpio)

This is off by one. Should be >=.

regards,
dan carpenter

> + return -EINVAL;
> +
> + ret = mux_control_select_delay(glm->mux, glm->gpio_mux_states[offset],
> + MUX_SELECT_DELAY_US);
> + if (ret < 0)
> + return ret;
> +
> + ret = gpiod_get_raw_value_cansleep(glm->muxed_gpio);
> + mux_control_deselect(glm->mux);
> + return ret;
> +}