Skip to content

Commit 07101e1

Browse files
diandersgregkh
authored andcommitted
pinctrl: qcom: spmi-gpio: Fix pmic_gpio_config_get() to be compliant
[ Upstream commit 1cf86bc ] If you do this on an sdm845 board: grep "" /sys/kernel/debug/pinctrl/*spmi:pmic*/pinconf-groups ...it looks like nonsense. For every pin you see listed: input bias disabled, input bias high impedance, input bias pull down, input bias pull up, ... That's because pmic_gpio_config_get() isn't complying with the rules that pinconf_generic_dump_one() expects. Specifically for boolean parameters (anything with a "struct pin_config_item" where has_arg is false) the function expects that the function should return its value not through the "config" parameter but should return "0" if the value is set and "-EINVAL" if the value isn't set. Let's fix this. >From a quick sample of other pinctrl drivers, it appears to be tradition to also return 1 through the config parameter for these boolean parameters when they exist. I'm not one to knock tradition, so I'll follow tradition and return 1 in these cases. While I'm at it, I'll also continue searching for four leaf clovers, kocking on wood three times, and trying not to break mirrors. NOTE: This also fixes an apparent typo for reading PIN_CONFIG_BIAS_DISABLE where the old driver was accidentally using "=" instead of "==" and thus was setting some internal state when you tried to query PIN_CONFIG_BIAS_DISABLE. Oops. Fixes: eadff30 ("pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver") Signed-off-by: Douglas Anderson <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a5d093d commit 07101e1

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,31 +390,47 @@ static int pmic_gpio_config_get(struct pinctrl_dev *pctldev,
390390

391391
switch (param) {
392392
case PIN_CONFIG_DRIVE_PUSH_PULL:
393-
arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_CMOS;
393+
if (pad->buffer_type != PMIC_GPIO_OUT_BUF_CMOS)
394+
return -EINVAL;
395+
arg = 1;
394396
break;
395397
case PIN_CONFIG_DRIVE_OPEN_DRAIN:
396-
arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS;
398+
if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS)
399+
return -EINVAL;
400+
arg = 1;
397401
break;
398402
case PIN_CONFIG_DRIVE_OPEN_SOURCE:
399-
arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS;
403+
if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS)
404+
return -EINVAL;
405+
arg = 1;
400406
break;
401407
case PIN_CONFIG_BIAS_PULL_DOWN:
402-
arg = pad->pullup == PMIC_GPIO_PULL_DOWN;
408+
if (pad->pullup != PMIC_GPIO_PULL_DOWN)
409+
return -EINVAL;
410+
arg = 1;
403411
break;
404412
case PIN_CONFIG_BIAS_DISABLE:
405-
arg = pad->pullup = PMIC_GPIO_PULL_DISABLE;
413+
if (pad->pullup != PMIC_GPIO_PULL_DISABLE)
414+
return -EINVAL;
415+
arg = 1;
406416
break;
407417
case PIN_CONFIG_BIAS_PULL_UP:
408-
arg = pad->pullup == PMIC_GPIO_PULL_UP_30;
418+
if (pad->pullup != PMIC_GPIO_PULL_UP_30)
419+
return -EINVAL;
420+
arg = 1;
409421
break;
410422
case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
411-
arg = !pad->is_enabled;
423+
if (pad->is_enabled)
424+
return -EINVAL;
425+
arg = 1;
412426
break;
413427
case PIN_CONFIG_POWER_SOURCE:
414428
arg = pad->power_source;
415429
break;
416430
case PIN_CONFIG_INPUT_ENABLE:
417-
arg = pad->input_enabled;
431+
if (!pad->input_enabled)
432+
return -EINVAL;
433+
arg = 1;
418434
break;
419435
case PIN_CONFIG_OUTPUT:
420436
arg = pad->out_value;

0 commit comments

Comments
 (0)