* [PATCH] pinctrl: rp1: Return -EINVAL for pin settings that are not enabled
@ 2026-11-30 6:30 Lin Tzu Yang
0 siblings, 0 replies; only message in thread
From: Lin Tzu Yang @ 2026-11-30 6:30 UTC (permalink / raw)
To: Linus Walleij, Andrea della Porta; +Cc: linux-gpio, linux-kernel
struct pinconf_ops says that pin_config_get() should return -EINVAL for
a setting that is supported but not enabled. rp1_pinconf_get() returns
0 with an argument of 0 instead, so callers can't tell an enabled
setting from a disabled one.
This shows up in debugfs, where the generic pinconf dump lists every
bias setting for every pin. With a pull-up set on GPIO17 of a Raspberry
Pi 5, pinconf-pins shows:
pin 17 (gpio17): input bias disabled, input bias pull down (0 ohms),
input bias pull up (1 ohms), output drive strength (4 mA), input
enabled, input schmitt enabled, output enabled, slew rate (0x0)
Return -EINVAL when a boolean setting is not enabled. The slew rate is
reported as a value, and 0 (slow) is a valid one, so leave it as is.
Tested on a Raspberry Pi 5 with the Raspberry Pi OS 6.18.39 kernel,
whose rp1_pinconf_get() has the same structure, by setting each bias on
GPIO17 through gpiolib and reading pinconf-pins:
- before: all 54 pins list all three bias settings, and all list both
input and output enabled
- after: GPIO17 lists only the bias that was set, no pin lists more
than one bias, and the 26 pins that list both input and output
enabled really have both enabled
The mainline change is build tested.
The bug was found and the patch written with the help of an AI coding
assistant (Claude). I tested it on hardware and reviewed the change.
Fixes: e3ce7b897388 ("pinctrl: rp1: Implement RaspberryPi RP1 pinmux/pinconf support")
Signed-off-by: Lin Tzu Yang <rongh7426@gmail.com>
---
drivers/pinctrl/pinctrl-rp1.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-rp1.c b/drivers/pinctrl/pinctrl-rp1.c
index dd0e85c2ca..7fabd61de5 100644
--- a/drivers/pinctrl/pinctrl-rp1.c
+++ b/drivers/pinctrl/pinctrl-rp1.c
@@ -1545,6 +1545,13 @@ static int rp1_pinconf_get(struct pinctrl_dev *pctldev, unsigned int offset,
return -ENOTSUPP;
}
+ /*
+ * A boolean setting that is supported but not enabled must return
+ * -EINVAL. The slew rate is a value, and 0 (slow) is valid.
+ */
+ if (!arg && param != PIN_CONFIG_SLEW_RATE)
+ return -EINVAL;
+
*config = pinconf_to_config_packed(param, arg);
return 0;
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-30 6:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 6:30 [PATCH] pinctrl: rp1: Return -EINVAL for pin settings that are not enabled Lin Tzu Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®