Skip to contentSkip to conversation

pinctrl: airoha: fix bias readback in airoha_pinconf_get()

PATCH In review Vikrant Yadav 2 participants 3 messages Oct 23 – Nov 20

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: airoha: fix bias readback in airoha_pinconf_get()

In airoha_pinconf_get(), the last branch of bias check "else if (pull_up || pull_down)", has no check on the requested parameter. It was meant to reject PIN_CONFIG_BIAS_DISABLE when a pull is enabled, but it also runs for PIN_CONFIG_BIAS_PULL_UP and PIN_CONFIG_BIAS_PULL_DOWN. When the pin really has that pull set, the earlier PULL_UP/PULL_DOWN checks do not reject it, so the execution reaches this branch, which returns -EINVAL. Reading back a pull-up or pull-down therefore always fails.

---
 drivers/pinctrl/airoha/pinctrl-airoha.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/airoha/pinctrl-airoha.c +1 -1
index f505a3f69c5d..8cf4592cbc73 100644
@@ -554,7 +554,7 @@ static int airoha_pinconf_get(struct pinctrl_dev *pctrl_dev,
 		else if (param == PIN_CONFIG_BIAS_PULL_DOWN &&
 			 !(pull_down && !pull_up))
 			return -EINVAL;
-		else if (pull_up || pull_down)
+		else if (param == PIN_CONFIG_BIAS_DISABLE && (pull_up || pull_down))
 			return -EINVAL;
 
 		arg = 1;
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 10 lines · Vikrant Yadav

In airoha_pinconf_get(), the last branch of bias check "else if (pull_up || pull_down)", has no check on the requested parameter. It was meant to reject PIN_CONFIG_BIAS_DISABLE when a pull is enabled, but it also runs for PIN_CONFIG_BIAS_PULL_UP and PIN_CONFIG_BIAS_PULL_DOWN. When the pin really has that pull set, the earlier PULL_UP/PULL_DOWN checks do not reject it, so the execution reaches this branch, which returns -EINVAL. Reading back a pull-up or pull-down therefore always fails.

Maybe Christian can ACK this patch if it looks right?

Yours,
Linus Walleij

#2 lore raw
Quoted 13 lines · Linus Walleij
Quoted 9 lines · Vikrant Yadav

In airoha_pinconf_get(), the last branch of bias check "else if (pull_up || pull_down)", has no check on the requested parameter. It was meant to reject PIN_CONFIG_BIAS_DISABLE when a pull is enabled, but it also runs for PIN_CONFIG_BIAS_PULL_UP and PIN_CONFIG_BIAS_PULL_DOWN. When the pin really has that pull set, the earlier PULL_UP/PULL_DOWN checks do not reject it, so the execution reaches this branch, which returns -EINVAL. Reading back a pull-up or pull-down therefore always fails.

Quoted 6 lines
Quoted 1 line

Maybe Christian can ACK this patch if it looks right?

Yours,
Linus Walleij

Hi Christian,

Just checking if you got a chance to look at this patch. If you want any changes, I can send a v2.

Thanks,
Vikrant