When reading back pin bias settings, if the pin is not in a
bias-disabled 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>
---
drivers/pinctrl/mediatek/pinctrl-paris.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index f9f9110f2107..1ca598ea7ba7 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -97,8 +97,8 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
if (err)
goto out;
if (param == PIN_CONFIG_BIAS_DISABLE) {
- if (ret == MTK_PUPD_SET_R1R0_00)
- ret = MTK_DISABLE;
+ if (ret != MTK_PUPD_SET_R1R0_00)
+ 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
--
2.34.1.575.g55b058a8bb-goog
Il 11/01/22 12:22, Chen-Yu Tsai ha scritto: > When reading back pin bias settings, if the pin is not in a > bias-disabled 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> > --- > drivers/pinctrl/mediatek/pinctrl-paris.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c > index f9f9110f2107..1ca598ea7ba7 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-paris.c > +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c > @@ -97,8 +97,8 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, > if (err) > goto out; > if (param == PIN_CONFIG_BIAS_DISABLE) { > - if (ret == MTK_PUPD_SET_R1R0_00) > - ret = MTK_DISABLE; > + if (ret != MTK_PUPD_SET_R1R0_00) > + 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 >
-----Original Message----- From: Chen-Yu Tsai <wenst@chromium.org> To: Sean Wang <sean.wang@kernel.org>, Linus Walleij < linus.walleij@linaro.org>, Matthias Brugger <matthias.bgg@gmail.com> Cc: Chen-Yu Tsai <wenst@chromium.org>, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Zhiyong Tao <zhiyong.tao@mediatek.com>, Guodong Liu < guodong.liu@mediatek.com> Subject: [PATCH 2/7] pinctrl: mediatek: paris: Fix PIN_CONFIG_BIAS_DISABLE readback Date: Tue, 11 Jan 2022 19:22:39 +0800 When reading back pin bias settings, if the pin is not in a bias-disabled 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> --- drivers/pinctrl/mediatek/pinctrl-paris.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c index f9f9110f2107..1ca598ea7ba7 100644 --- a/drivers/pinctrl/mediatek/pinctrl-paris.c +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c @@ -97,8 +97,8 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, if (err) goto out; if (param == PIN_CONFIG_BIAS_DISABLE) { - if (ret == MTK_PUPD_SET_R1R0_00) - ret = MTK_DISABLE; + if (ret != MTK_PUPD_SET_R1R0_00) + err = -EINVAL; Hi Chen-Yu When tht API "hw->soc->bias_get_combo(hw, desc, &pullup, &ret)" is called, The ret vaule of may be MTK_DISABLE OR MTK_PUPD_SET_R1R0_00 or (pullen == 0), All those cases are expected to be as "bias-disable". We advices to keep original code, + if (ret == MTK_PUPD_SET_R1R0_00) + ret = MTK_DISABLE; + if (ret != MTK_DISABLE) + err = -EINVAL; Thanks } else if (param == PIN_CONFIG_BIAS_PULL_UP) { /* When desire to get pull-up value, return * error if current setting is pull- down
On Wed, Jan 19, 2022 at 9:42 AM Guodong Liu <guodong.liu@mediatek.com> wrote: > > -----Original Message----- > From: Chen-Yu Tsai <wenst@chromium.org> > To: Sean Wang <sean.wang@kernel.org>, Linus Walleij < > linus.walleij@linaro.org>, Matthias Brugger <matthias.bgg@gmail.com> > Cc: Chen-Yu Tsai <wenst@chromium.org>, > linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, > linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, > Zhiyong Tao <zhiyong.tao@mediatek.com>, Guodong Liu < > guodong.liu@mediatek.com> > Subject: [PATCH 2/7] pinctrl: mediatek: paris: Fix > PIN_CONFIG_BIAS_DISABLE readback > Date: Tue, 11 Jan 2022 19:22:39 +0800 > > When reading back pin bias settings, if the pin is not in a > bias-disabled 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> > --- > drivers/pinctrl/mediatek/pinctrl-paris.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c > b/drivers/pinctrl/mediatek/pinctrl-paris.c > index f9f9110f2107..1ca598ea7ba7 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-paris.c > +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c > @@ -97,8 +97,8 @@ static int mtk_pinconf_get(struct pinctrl_dev > *pctldev, > if (err) > goto out; > if (param == PIN_CONFIG_BIAS_DISABLE) { > - if (ret == MTK_PUPD_SET_R1R0_00) > - ret = MTK_DISABLE; > + if (ret != MTK_PUPD_SET_R1R0_00) > + err = -EINVAL; > Hi Chen-Yu > > When tht API "hw->soc->bias_get_combo(hw, desc, &pullup, &ret)" is > called, > The ret vaule of may be MTK_DISABLE OR MTK_PUPD_SET_R1R0_00 or (pullen > == 0), All those cases are expected to be as "bias-disable". > We advices to keep original code, > + if (ret == MTK_PUPD_SET_R1R0_00) > + > ret = MTK_DISABLE; > + if (ret != MTK_DISABLE) > + err = -EINVAL; IIUC you are suggesting to assign MTK_DISABLE to ret in the other two cases, and then check if ret == MTK_DISABLE. Thanks for pointing that out. ChenYu > Thanks > } else if (param == PIN_CONFIG_BIAS_PULL_UP) { > /* When desire to get pull-up value, > return > * error if current setting is pull- > down >
-----Original Message----- From: Chen-Yu Tsai <wenst@chromium.org> To: Guodong Liu <guodong.liu@mediatek.com> Cc: Sean Wang <sean.wang@kernel.org>, Linus Walleij < linus.walleij@linaro.org>, Matthias Brugger <matthias.bgg@gmail.com>, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Zhiyong Tao <zhiyong.tao@mediatek.com>, Hui Liu <hui.liu@mediatek.com>, Light Hsieh <light.hsieh@mediatek.com> Subject: Re: [PATCH 2/7] pinctrl: mediatek: paris: Fix PIN_CONFIG_BIAS_DISABLE readback Date: Wed, 19 Jan 2022 13:57:18 +0800 On Wed, Jan 19, 2022 at 9:42 AM Guodong Liu <guodong.liu@mediatek.com> wrote: > > -----Original Message----- > From: Chen-Yu Tsai <wenst@chromium.org> > To: Sean Wang <sean.wang@kernel.org>, Linus Walleij < > linus.walleij@linaro.org>, Matthias Brugger <matthias.bgg@gmail.com> > Cc: Chen-Yu Tsai <wenst@chromium.org>, > linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, > linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, > Zhiyong Tao <zhiyong.tao@mediatek.com>, Guodong Liu < > guodong.liu@mediatek.com> > Subject: [PATCH 2/7] pinctrl: mediatek: paris: Fix > PIN_CONFIG_BIAS_DISABLE readback > Date: Tue, 11 Jan 2022 19:22:39 +0800 > > When reading back pin bias settings, if the pin is not in a > bias-disabled 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> > --- > drivers/pinctrl/mediatek/pinctrl-paris.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c > b/drivers/pinctrl/mediatek/pinctrl-paris.c > index f9f9110f2107..1ca598ea7ba7 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-paris.c > +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c > @@ -97,8 +97,8 @@ static int mtk_pinconf_get(struct pinctrl_dev > *pctldev, > if (err) > goto out; > if (param == PIN_CONFIG_BIAS_DISABLE) { > - if (ret == MTK_PUPD_SET_R1R0_00) > - ret = MTK_DISABLE; > + if (ret != MTK_PUPD_SET_R1R0_00) > + err = -EINVAL; > Hi Chen-Yu > > When the API "hw->soc->bias_get_combo(hw, desc, &pullup, &ret)" is > called, > The ret vaule of ret may be MTK_DISABLE or MTK_PUPD_SET_R1R0_00 > or (pullen > == 0), All those cases are expected to be as "bias-disable". > We advices to keep original code, > + if (ret == MTK_PUPD_SET_R1R0_00) > + ret = MTK_DISABLE; > + if (ret != MTK_DISABLE) > + err = -EINVAL; IIUC you are suggesting to assign MTK_DISABLE to ret in the other two cases, and then check if ret == MTK_DISABLE. Thanks for pointing that out. ChenYu > Thanks Hi Chen-Yu Yes, just for pins with config of MTK_PUPD_SET_R1R0_00 are required to do additional assignment operations(ret = MTK_DISABLE;), in the other two cases, the assignment operations of ret as MTK_DISABLE is obtained by function call "hw->soc->bias_get_combo(hw, desc, &pullup, &ret)". Thanks > } else if (param == PIN_CONFIG_BIAS_PULL_UP) > { > /* When desire to get pull-up value, > return > * error if current setting is pull- > down >
© 2016 - 2024 Red Hat, Inc.