Re: [PATCH 11/11] pinctrl: scmi: select the GPIO function on GPIO requests
From: Andy Shevchenko
Date: Tue Nov 03 2026 - 08:45:24 EST
On Fri, Oct 30, 2026 at 04:58:42PM +0100, Clément Le Goffic wrote:
> On a GPIO request, select the GPIO function of the pin, on the pin for a
> pin-only function or on its single-pin group. Without a GPIO function the
> mux is left as it is.
...
> +static int pinctrl_scmi_gpio_mux_set(struct scmi_pinctrl *pmx, unsigned int pin)
> +{
> + const unsigned int *elems, *pins;
> + unsigned int nr_elems, nr_pins, i;
> + bool pin_only, gpio;
> + int nr_functions, func, ret;
> +
> + nr_functions = pinctrl_ops->count_get(pmx->ph, FUNCTION_TYPE);
Is nr_functions signed for a purpose? Can it hold an error code?
> + for (func = 0; func < nr_functions; func++) {
for (int func = 0; func < nr_functions; func++) {
> + ret = pinctrl_ops->function_flags_get(pmx->ph, func, &pin_only,
> + &gpio);
> + if (ret)
> + return ret;
> +
> + if (!gpio)
> + continue;
> +
> + ret = pinctrl_ops->function_groups_get(pmx->ph, func, &nr_elems,
> + &elems);
> + if (ret)
> + return ret;
> + for (i = 0; i < nr_elems; i++) {
for (unsigned int i = 0; i < nr_elems; i++) {
> + if (pin_only) {
> + if (elems[i] != pin)
> + continue;
> +
> + return pinctrl_ops->pin_mux_set(pmx->ph, func,
> + pin);
> + }
> +
> + ret = pinctrl_ops->group_pins_get(pmx->ph, elems[i],
> + &pins, &nr_pins);
> + if (ret)
> + return ret;
> +
> + if (nr_pins == 1 && pins[0] == pin)
> + return pinctrl_ops->mux_set(pmx->ph, func,
> + elems[i]);
> + }
> + }
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko