Skip to content

Commit b5fe46e

Browse files
matthijskooijmanlinusw
authored andcommitted
pinctrl: single: Fix PIN_CONFIG_BIAS_DISABLE handling
The pinctrl-single driver handles pin_config_set by looking up the requested setting in a DT-defined lookup table, which defines what bits correspond to each setting. There is no way to add PIN_CONFIG_BIAS_DISABLE entries to the table, since there is instead code to disable the bias by applying the disable values of both the pullup and pulldown entries in the table. However, this code is inside the table-lookup loop, so it would only execute if there is an entry for PIN_CONFIG_BIAS_DISABLE in the table, which can never exist, so this code never runs. This commit lifts the offending code out of the loop, so it just executes directly whenever PIN_CONFIG_BIAS_DISABLE is requested, skippipng the table lookup loop. This also introduces a new `param` variable to make the code slightly more readable. This bug seems to have existed when this code was first merged in commit 9dddb4d ("pinctrl: single: support generic pinconf"). Earlier versions of this patch did have an entry for PIN_CONFIG_BIAS_DISABLE in the lookup table, but that was removed, which is probably how this bug was introduced. Signed-off-by: Matthijs Kooijman <[email protected]> Reviewed-by: Haojian Zhuang <[email protected]> Reviewed-by: Tony Lindgren <[email protected]> Message-ID: <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent a95e2bc commit b5fe46e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/pinctrl/pinctrl-single.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,21 +550,30 @@ static int pcs_pinconf_set(struct pinctrl_dev *pctldev,
550550
unsigned offset = 0, shift = 0, i, data, ret;
551551
u32 arg;
552552
int j;
553+
enum pin_config_param param;
553554

554555
ret = pcs_get_function(pctldev, pin, &func);
555556
if (ret)
556557
return ret;
557558

558559
for (j = 0; j < num_configs; j++) {
560+
param = pinconf_to_config_param(configs[j]);
561+
562+
/* BIAS_DISABLE has no entry in the func->conf table */
563+
if (param == PIN_CONFIG_BIAS_DISABLE) {
564+
/* This just disables all bias entries */
565+
pcs_pinconf_clear_bias(pctldev, pin);
566+
continue;
567+
}
568+
559569
for (i = 0; i < func->nconfs; i++) {
560-
if (pinconf_to_config_param(configs[j])
561-
!= func->conf[i].param)
570+
if (param != func->conf[i].param)
562571
continue;
563572

564573
offset = pin * (pcs->width / BITS_PER_BYTE);
565574
data = pcs->read(pcs->base + offset);
566575
arg = pinconf_to_config_argument(configs[j]);
567-
switch (func->conf[i].param) {
576+
switch (param) {
568577
/* 2 parameters */
569578
case PIN_CONFIG_INPUT_SCHMITT:
570579
case PIN_CONFIG_DRIVE_STRENGTH:
@@ -576,9 +585,6 @@ static int pcs_pinconf_set(struct pinctrl_dev *pctldev,
576585
data |= (arg << shift) & func->conf[i].mask;
577586
break;
578587
/* 4 parameters */
579-
case PIN_CONFIG_BIAS_DISABLE:
580-
pcs_pinconf_clear_bias(pctldev, pin);
581-
break;
582588
case PIN_CONFIG_BIAS_PULL_DOWN:
583589
case PIN_CONFIG_BIAS_PULL_UP:
584590
if (arg)

0 commit comments

Comments
 (0)