]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pinctrl: mediatek: paris: Fix PIN_CONFIG_BIAS_* readback
authorChen-Yu Tsai <wenst@chromium.org>
Tue, 8 Mar 2022 10:09:47 +0000 (18:09 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 May 2024 09:43:47 +0000 (11:43 +0200)
[ Upstream commit 3e8c6bc608480010f360c4a59578d7841726137d ]

When reading back pin bias settings, if the pin is not in the
corresponding bias state, the function should return -EINVAL.

Fix this in the mediatek-paris pinctrl library so that the read back
state is not littered with bogus a "input bias disabled" combined with
"pull up" or "pull down" states.

Fixes: 805250982bb5 ("pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220308100956.2750295-3-wenst@chromium.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Stable-dep-of: c5d3b64c568a ("pinctrl: mediatek: paris: Rework support for PIN_CONFIG_{INPUT,OUTPUT}_ENABLE")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pinctrl/mediatek/pinctrl-paris.c

index b613dda50151ba1ef70de9a4508e9c1a3f71b5e4..cb4979cefdd09821d7ea48aace525a5303dfae3c 100644 (file)
@@ -95,20 +95,16 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
                        err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
                        if (err)
                                goto out;
+                       if (ret == MTK_PUPD_SET_R1R0_00)
+                               ret = MTK_DISABLE;
                        if (param == PIN_CONFIG_BIAS_DISABLE) {
-                               if (ret == MTK_PUPD_SET_R1R0_00)
-                                       ret = MTK_DISABLE;
+                               if (ret != MTK_DISABLE)
+                                       err = -EINVAL;
                        } else if (param == PIN_CONFIG_BIAS_PULL_UP) {
-                               /* When desire to get pull-up value, return
-                                *  error if current setting is pull-down
-                                */
-                               if (!pullup)
+                               if (!pullup || ret == MTK_DISABLE)
                                        err = -EINVAL;
                        } else if (param == PIN_CONFIG_BIAS_PULL_DOWN) {
-                               /* When desire to get pull-down value, return
-                                *  error if current setting is pull-up
-                                */
-                               if (pullup)
+                               if (pullup || ret == MTK_DISABLE)
                                        err = -EINVAL;
                        }
                } else {