Return -ENOTSUPP instead of -EINVAL when encountering unsupported pin
configuration parameters. This is more logical and allows the GPIO
subsystem to gracefully handle unsupported parameters via functions like
gpio_set_config_with_argument_optional(), which specifically ignores
-ENOTSUPP but treats others as failure.
Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech>
---
drivers/pinctrl/spacemit/pinctrl-k1.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/pinctrl/spacemit/pinctrl-k1.c b/drivers/pinctrl/spacemit/pinctrl-k1.c
index 62cab6f6cd0a..b0be62b1c816 100644
--- a/drivers/pinctrl/spacemit/pinctrl-k1.c
+++ b/drivers/pinctrl/spacemit/pinctrl-k1.c
@@ -674,7 +674,7 @@ static int spacemit_pinconf_get(struct pinctrl_dev *pctldev,
arg = 0;
break;
default:
- return -EINVAL;
+ return -ENOTSUPP;
}
*config = pinconf_to_config_packed(param, arg);
@@ -740,7 +740,7 @@ static int spacemit_pinconf_generate_config(struct spacemit_pinctrl *pctrl,
}
break;
default:
- return -EINVAL;
+ return -ENOTSUPP;
}
}
@@ -814,10 +814,12 @@ static int spacemit_pinconf_set(struct pinctrl_dev *pctldev,
struct spacemit_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
const struct spacemit_pin *spin = spacemit_get_pin(pctrl, pin);
u32 value;
+ int ret;
- if (spacemit_pinconf_generate_config(pctrl, spin, pctrl->data->dconf,
- configs, num_configs, &value))
- return -EINVAL;
+ ret = spacemit_pinconf_generate_config(pctrl, spin, pctrl->data->dconf,
+ configs, num_configs, &value);
+ if (ret)
+ return ret;
return spacemit_pin_set_config(pctrl, pin, value);
}
@@ -831,16 +833,17 @@ static int spacemit_pinconf_group_set(struct pinctrl_dev *pctldev,
const struct spacemit_pin *spin;
const struct group_desc *group;
u32 value;
- int i;
+ int i, ret;
group = pinctrl_generic_get_group(pctldev, gsel);
if (!group)
return -EINVAL;
spin = spacemit_get_pin(pctrl, group->grp.pins[0]);
- if (spacemit_pinconf_generate_config(pctrl, spin, pctrl->data->dconf,
- configs, num_configs, &value))
- return -EINVAL;
+ ret = spacemit_pinconf_generate_config(pctrl, spin, pctrl->data->dconf,
+ configs, num_configs, &value);
+ if (ret)
+ return ret;
for (i = 0; i < group->grp.npins; i++)
spacemit_pin_set_config(pctrl, group->grp.pins[i], value);
--
2.53.0
Hi Junhui, On Thu, 12 Mar 2026 at 14:14, Junhui Liu <junhui.liu@pigmoral.tech> wrote: > > Return -ENOTSUPP instead of -EINVAL when encountering unsupported pin > configuration parameters. This is more logical and allows the GPIO > subsystem to gracefully handle unsupported parameters via functions like > gpio_set_config_with_argument_optional(), which specifically ignores > -ENOTSUPP but treats others as failure. > > Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> > --- Reviewed-by: Anand Moon <linux.amoon@gmail.com> Thanks -Anand
On Thu, Mar 12, 2026 at 9:43 AM Junhui Liu <junhui.liu@pigmoral.tech> wrote: > > Return -ENOTSUPP instead of -EINVAL when encountering unsupported pin > configuration parameters. This is more logical and allows the GPIO > subsystem to gracefully handle unsupported parameters via functions like > gpio_set_config_with_argument_optional(), which specifically ignores > -ENOTSUPP but treats others as failure. > > Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> > --- Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
On Thu, Mar 12, 2026 at 04:42:42PM +0800, Junhui Liu wrote: > Return -ENOTSUPP instead of -EINVAL when encountering unsupported pin > configuration parameters. This is more logical and allows the GPIO > subsystem to gracefully handle unsupported parameters via functions like > gpio_set_config_with_argument_optional(), which specifically ignores > -ENOTSUPP but treats others as failure. This sounds like a fix and deserves Fixes tag, though I'm not sure whether backporting is appropriate since no existing system should be affected... Regards, Yao Zi
© 2016 - 2026 Red Hat, Inc.