Skip to content

Commit 203a831

Browse files
author
Linus Walleij
committed
pinctrl: generic: rename PIN_CONFIG_OUTPUT to LEVEL
This generic pin config property is confusingly named so let's rename it to make things clearer. There are already drivers in the tree that use PIN_CONFIG_OUTPUT to *read* the value of an output driven pin, which is a big semantic confusion for the head: are we then reading the setting of the output or the actual value/level that is put out on the pin? We already have PIN_CONFIG_OUTPUT_ENABLE that turns on driver buffers for output, so this can by logical conclusion only drive the voltage level if it should be any different. But if we read the pin, are we then reading the *setting* of the output value or the *actual* value we can see on the line? If the pin has not first been set into output mode with PIN_CONFIG_OUTPUT_ENABLE, but is instead in some input mode or tristate, what will reading this property actually return? Reading the current users reading this property it is clear that what we read is the logical level of the pin as 0 or 1 depending on if it is low or high. Rename it to PIN_CONFIG_LEVEL so it is crystal clear that we set or read the voltage level of the pin and nothing else. Acked-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 6c3442b commit 203a831

39 files changed

Lines changed: 91 additions & 87 deletions

Documentation/driver-api/pin-control.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ has to be handled by the ``<linux/gpio/consumer.h>`` interface. Instead view thi
863863
a certain pin config setting. Look in e.g. ``<linux/pinctrl/pinconf-generic.h>``
864864
and you find this in the documentation:
865865

866-
PIN_CONFIG_OUTPUT:
866+
PIN_CONFIG_LEVEL:
867867
this will configure the pin in output, use argument
868868
1 to indicate high level, argument 0 to indicate low level.
869869

@@ -897,7 +897,7 @@ And your machine configuration may look like this:
897897
};
898898
899899
static unsigned long uart_sleep_mode[] = {
900-
PIN_CONF_PACKED(PIN_CONFIG_OUTPUT, 0),
900+
PIN_CONF_PACKED(PIN_CONFIG_LEVEL, 0),
901901
};
902902
903903
static struct pinctrl_map pinmap[] __initdata = {

drivers/gpio/gpio-rockchip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
769769
list_del(&cfg->head);
770770

771771
switch (cfg->param) {
772-
case PIN_CONFIG_OUTPUT:
772+
case PIN_CONFIG_LEVEL:
773773
ret = rockchip_gpio_direction_output(&bank->gpio_chip, cfg->pin, cfg->arg);
774774
if (ret)
775775
dev_warn(dev, "setting output pin %u to %u failed\n", cfg->pin,

drivers/pinctrl/bcm/pinctrl-bcm2835.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ static int bcm2835_pinconf_get(struct pinctrl_dev *pctldev,
10231023
/* No way to read back bias config in HW */
10241024

10251025
switch (param) {
1026-
case PIN_CONFIG_OUTPUT:
1026+
case PIN_CONFIG_LEVEL:
10271027
if (fsel != BCM2835_FSEL_GPIO_OUT)
10281028
return -EINVAL;
10291029

@@ -1091,7 +1091,7 @@ static int bcm2835_pinconf_set(struct pinctrl_dev *pctldev,
10911091
break;
10921092

10931093
/* Set output-high or output-low */
1094-
case PIN_CONFIG_OUTPUT:
1094+
case PIN_CONFIG_LEVEL:
10951095
bcm2835_gpio_set_bit(pc, arg ? GPSET0 : GPCLR0, pin);
10961096
break;
10971097

@@ -1202,7 +1202,7 @@ static int bcm2711_pinconf_set(struct pinctrl_dev *pctldev,
12021202
break;
12031203

12041204
/* Set output-high or output-low */
1205-
case PIN_CONFIG_OUTPUT:
1205+
case PIN_CONFIG_LEVEL:
12061206
bcm2835_gpio_set_bit(pc, arg ? GPSET0 : GPCLR0, pin);
12071207
break;
12081208

drivers/pinctrl/cirrus/pinctrl-madera-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ static int madera_pin_conf_get(struct pinctrl_dev *pctldev, unsigned int pin,
804804
if (conf[0] & MADERA_GP1_IP_CFG_MASK)
805805
result = 1;
806806
break;
807-
case PIN_CONFIG_OUTPUT:
807+
case PIN_CONFIG_LEVEL:
808808
if ((conf[1] & MADERA_GP1_DIR_MASK) &&
809809
(conf[0] & MADERA_GP1_LVL_MASK))
810810
result = 1;
@@ -902,7 +902,7 @@ static int madera_pin_conf_set(struct pinctrl_dev *pctldev, unsigned int pin,
902902
mask[1] |= MADERA_GP1_DIR_MASK;
903903
conf[1] |= MADERA_GP1_DIR;
904904
break;
905-
case PIN_CONFIG_OUTPUT:
905+
case PIN_CONFIG_LEVEL:
906906
val = pinconf_to_config_argument(*configs);
907907
mask[0] |= MADERA_GP1_LVL_MASK;
908908
if (val)

drivers/pinctrl/mediatek/pinctrl-airoha.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2765,7 +2765,7 @@ static int airoha_pinconf_set(struct pinctrl_dev *pctrl_dev,
27652765
break;
27662766
case PIN_CONFIG_OUTPUT_ENABLE:
27672767
case PIN_CONFIG_INPUT_ENABLE:
2768-
case PIN_CONFIG_OUTPUT: {
2768+
case PIN_CONFIG_LEVEL: {
27692769
bool input = param == PIN_CONFIG_INPUT_ENABLE;
27702770
int err;
27712771

@@ -2774,7 +2774,7 @@ static int airoha_pinconf_set(struct pinctrl_dev *pctrl_dev,
27742774
if (err)
27752775
return err;
27762776

2777-
if (param == PIN_CONFIG_OUTPUT) {
2777+
if (param == PIN_CONFIG_LEVEL) {
27782778
err = airoha_pinconf_set_pin_value(pctrl_dev,
27792779
pin, !!arg);
27802780
if (err)

drivers/pinctrl/mediatek/pinctrl-moore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
332332
goto err;
333333

334334
break;
335-
case PIN_CONFIG_OUTPUT:
335+
case PIN_CONFIG_LEVEL:
336336
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
337337
MTK_OUTPUT);
338338
if (err)

drivers/pinctrl/mediatek/pinctrl-mtk-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev,
384384
mtk_pmx_gpio_set_direction(pctldev, NULL, pin, true);
385385
ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param);
386386
break;
387-
case PIN_CONFIG_OUTPUT:
387+
case PIN_CONFIG_LEVEL:
388388
mtk_gpio_set(pctl->chip, pin, arg);
389389
ret = mtk_pmx_gpio_set_direction(pctldev, NULL, pin, false);
390390
break;

drivers/pinctrl/mediatek/pinctrl-paris.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
169169
if (!ret)
170170
err = -EINVAL;
171171
break;
172-
case PIN_CONFIG_OUTPUT:
172+
case PIN_CONFIG_LEVEL:
173173
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &ret);
174174
if (err)
175175
break;
@@ -292,7 +292,7 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
292292
/* regard all non-zero value as enable */
293293
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SR, !!arg);
294294
break;
295-
case PIN_CONFIG_OUTPUT:
295+
case PIN_CONFIG_LEVEL:
296296
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO,
297297
arg);
298298
if (err)

drivers/pinctrl/meson/pinctrl-amlogic-a4.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static int aml_pinconf_get(struct pinctrl_dev *pcdev, unsigned int pin,
422422
return -EINVAL;
423423
arg = 1;
424424
break;
425-
case PIN_CONFIG_OUTPUT:
425+
case PIN_CONFIG_LEVEL:
426426
ret = aml_pinconf_get_output(info, pin);
427427
if (ret <= 0)
428428
return -EINVAL;
@@ -568,7 +568,7 @@ static int aml_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
568568
switch (param) {
569569
case PIN_CONFIG_DRIVE_STRENGTH_UA:
570570
case PIN_CONFIG_OUTPUT_ENABLE:
571-
case PIN_CONFIG_OUTPUT:
571+
case PIN_CONFIG_LEVEL:
572572
arg = pinconf_to_config_argument(configs[i]);
573573
break;
574574

@@ -592,7 +592,7 @@ static int aml_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
592592
case PIN_CONFIG_OUTPUT_ENABLE:
593593
ret = aml_pinconf_set_output(info, pin, arg);
594594
break;
595-
case PIN_CONFIG_OUTPUT:
595+
case PIN_CONFIG_LEVEL:
596596
ret = aml_pinconf_set_output_drive(info, pin, arg);
597597
break;
598598
default:

drivers/pinctrl/meson/pinctrl-meson.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
360360
switch (param) {
361361
case PIN_CONFIG_DRIVE_STRENGTH_UA:
362362
case PIN_CONFIG_OUTPUT_ENABLE:
363-
case PIN_CONFIG_OUTPUT:
363+
case PIN_CONFIG_LEVEL:
364364
arg = pinconf_to_config_argument(configs[i]);
365365
break;
366366

@@ -384,7 +384,7 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
384384
case PIN_CONFIG_OUTPUT_ENABLE:
385385
ret = meson_pinconf_set_output(pc, pin, arg);
386386
break;
387-
case PIN_CONFIG_OUTPUT:
387+
case PIN_CONFIG_LEVEL:
388388
ret = meson_pinconf_set_output_drive(pc, pin, arg);
389389
break;
390390
default:
@@ -502,7 +502,7 @@ static int meson_pinconf_get(struct pinctrl_dev *pcdev, unsigned int pin,
502502
return -EINVAL;
503503
arg = 1;
504504
break;
505-
case PIN_CONFIG_OUTPUT:
505+
case PIN_CONFIG_LEVEL:
506506
ret = meson_pinconf_get_output(pc, pin);
507507
if (ret <= 0)
508508
return -EINVAL;

0 commit comments

Comments
 (0)