All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Clément Le Goffic" <clegoffic@baylibre.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH 04/11] pinctrl: scmi: report an off setting as not set
Date: Fri, 30 Oct 2026 16:09:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-191219@kernel.org> (raw)
In-Reply-To: <20261030-clegoffic-pinctrl-scmi-gpio-v1-4-52d92843ad97@baylibre.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pinctrl: scmi: -EINVAL in pinctrl_scmi_pinconf_get() breaks GPIO get_direction
--

commit 925e342f7e0510b1b9dda63effb86ab92324b2e4
Author: Clément Le Goffic <clegoffic@baylibre.com>

pinctrl: scmi: report an off setting as not set

This commit changes the SCMI pinctrl driver to return -EINVAL when
querying boolean or pull pinconf parameters whose platform value is 0, so
that inactive settings are not reported as set.

> diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
> index f74ef0952ba9b..355ad26cb2156 100644
> --- a/drivers/pinctrl/pinctrl-scmi.c
> +++ b/drivers/pinctrl/pinctrl-scmi.c
> @@ -153,13 +153,41 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
>  	return 0;
>  }
>  
> -static u32 pinctrl_scmi_map_pinconf_arg_get(enum pin_config_param param,
> -					    u32 value)
> +static bool pinctrl_scmi_pinconf_inactive_flag(enum pin_config_param param,
> +					       u32 value)
>  {
> +	if (value)
> +		return false;
> +
> +	switch (param) {
> +	case PIN_CONFIG_BIAS_BUS_HOLD:
> +	case PIN_CONFIG_BIAS_DISABLE:
> +	case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
> +	case PIN_CONFIG_BIAS_PULL_DOWN:
> +	case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
> +	case PIN_CONFIG_BIAS_PULL_UP:
> +	case PIN_CONFIG_DRIVE_OPEN_DRAIN:
> +	case PIN_CONFIG_DRIVE_OPEN_SOURCE:
> +	case PIN_CONFIG_DRIVE_PUSH_PULL:
> +	case PIN_CONFIG_INPUT_ENABLE:
> +	case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
> +	case PIN_CONFIG_OUTPUT_ENABLE:
> +		return true;
> +	default:
> +		return false;
> +	}
> +}
> +
> +static int pinctrl_scmi_map_pinconf_arg_get(enum pin_config_param param,
> +					    u32 *value)
> +{
> +	if (pinctrl_scmi_pinconf_inactive_flag(param, *value))
> +		return -EINVAL;
> +
>  	if (param == PIN_CONFIG_DRIVE_STRENGTH)
> -		return value / MILLI;
> +		*value /= MILLI;
>  
> -	return value;
> +	return 0;
>  }
>  
>  static int pinctrl_scmi_map_pinconf_type_get(enum pin_config_param param,
> @@ -232,7 +260,10 @@ static int pinctrl_scmi_pinconf_get(struct pinctrl_dev *pctldev,
>  	if (ret)
>  		return ret;
>  
> -	config_value = pinctrl_scmi_map_pinconf_arg_get(config_type, config_value);
> +	ret = pinctrl_scmi_map_pinconf_arg_get(config_type, &config_value);
> +	if (ret)
> +		return ret;

[Severity: High]
Does returning -EINVAL for PIN_CONFIG_OUTPUT_ENABLE when config_value is 0
break pin_control_gpio_get_direction() in drivers/gpio/gpio-by-pinctrl.c
for scmi-pinctrl-gpio?

In drivers/gpio/gpio-by-pinctrl.c, pin_control_gpio_get_direction()
queries the pin direction through pinctrl_gpio_get_config() ->
pin_config_get_for_pin() -> pinctrl_scmi_pinconf_get():

drivers/gpio/gpio-by-pinctrl.c:pin_control_gpio_get_direction() {
	config = PIN_CONFIG_OUTPUT_ENABLE;
	ret = pinctrl_gpio_get_config(gc, offset, &config);
	if (ret)
		return ret;
	if (config)
		return GPIO_LINE_DIRECTION_OUT;

	return GPIO_LINE_DIRECTION_IN;
}

When a pin has output mode disabled (SCMI_PIN_OUTPUT_MODE is 0, meaning
the pin is an input), pinctrl_scmi_pinconf_inactive_flag() now returns
true for PIN_CONFIG_OUTPUT_ENABLE, so pinctrl_scmi_pinconf_get() returns
-EINVAL.

Because pin_control_gpio_get_direction() returns ret immediately when it
is non-zero, querying the direction of any input line via
gpiod_get_direction() or gpiochip_lock_as_irq() will fail with -EINVAL,
and GPIO_LINE_DIRECTION_IN becomes unreachable.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261030-clegoffic-pinctrl-scmi-gpio-v1-0-52d92843ad97@baylibre.com?part=4

  reply	other threads:[~2026-10-30 16:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 15:58 [PATCH 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
2026-10-30 15:58 ` [PATCH 01/11] pinctrl: scmi: send the drive strength in microamperes Clément Le Goffic
2026-10-30 15:58 ` [PATCH 02/11] pinctrl: scmi: map the schmitt trigger enable to its SCMI type Clément Le Goffic
2026-10-30 15:58 ` [PATCH 03/11] pinctrl: scmi: send the settings without argument as enabled Clément Le Goffic
2026-10-30 15:58 ` [PATCH 04/11] pinctrl: scmi: report an off setting as not set Clément Le Goffic
2026-10-30 16:09   ` sashiko-bot [this message]
2026-10-30 15:58 ` [PATCH 05/11] firmware: arm_scmi: stop reading past PINCTRL_LIST_ASSOCIATIONS replies Clément Le Goffic
2026-10-30 15:58 ` [PATCH 06/11] firmware: arm_scmi: report the pin-only and GPIO flags of functions Clément Le Goffic
2026-10-30 15:58 ` [PATCH 07/11] pinctrl: scmi: give no groups to pin-only functions Clément Le Goffic
2026-10-30 15:58 ` [PATCH 08/11] pinctrl: scmi: mark the GPIO functions Clément Le Goffic
2026-10-30 15:58 ` [PATCH 09/11] pinctrl: scmi: report whether a function is GPIO Clément Le Goffic
2026-10-30 15:58 ` [PATCH 10/11] firmware: arm_scmi: add an operation to set the function of a single pin Clément Le Goffic
2026-10-30 15:58 ` [PATCH 11/11] pinctrl: scmi: select the GPIO function on GPIO requests Clément Le Goffic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-191219@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=clegoffic@baylibre.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.