[2/2] pinctrl: mediatek: mt7622: align error handling of mtk_hw_get_value call

Message ID 0eb8fd904f9b49d0e992bc2ee725d057f94cf735.1515514758.git.sean.wang@mediatek.com
State New
Headers show
Series
  • [1/2] pinctrl: mediatek: mt7622: fix potential uninitialized value being returned
Related show

Commit Message

Sean Wang Jan. 9, 2018, 4:28 p.m.
From: Sean Wang <sean.wang@mediatek.com>

Make consistent error handling of all mtk_hw_get_value occurrences using
propagating error code from the internal instead of creating a new one.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/pinctrl/mediatek/pinctrl-mt7622.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Matthias Brugger Jan. 10, 2018, 9:01 a.m. | #1
On 01/09/2018 05:28 PM, sean.wang@mediatek.com wrote:
> From: Sean Wang <sean.wang@mediatek.com>
> 
> Make consistent error handling of all mtk_hw_get_value occurrences using
> propagating error code from the internal instead of creating a new one.
> 
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> -->  drivers/pinctrl/mediatek/pinctrl-mt7622.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
> index dc32e3c..06e8406 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
> @@ -1160,7 +1160,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
>  	case PIN_CONFIG_OUTPUT_ENABLE:
>  		err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_DIR, &val);
>  		if (err)
> -			return -EINVAL;
> +			return err;
>  
>  		/* HW takes input mode as zero; output mode as non-zero */
>  		if ((val && param == PIN_CONFIG_INPUT_ENABLE) ||
> @@ -1184,11 +1184,11 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
>  	case PIN_CONFIG_DRIVE_STRENGTH:
>  		err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E4, &val);
>  		if (err)
> -			return -EINVAL;
> +			return err;
>  
>  		err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E8, &val2);
>  		if (err)
> -			return -EINVAL;
> +			return err;
>  
>  		/* 4mA when (e8, e4) = (0, 0); 8mA when (e8, e4) = (0, 1)
>  		 * 12mA when (e8, e4) = (1, 0); 16mA when (e8, e4) = (1, 1)
> @@ -1203,7 +1203,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
>  
>  		err = mtk_hw_get_value(hw, pin, reg, &val);
>  		if (err)
> -			return -EINVAL;
> +			return err;
>  
>  		ret = val;
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Jan. 11, 2018, 9:44 a.m. | #2
On Tue, Jan 9, 2018 at 5:28 PM,  <sean.wang@mediatek.com> wrote:

> From: Sean Wang <sean.wang@mediatek.com>
>
> Make consistent error handling of all mtk_hw_get_value occurrences using
> propagating error code from the internal instead of creating a new one.
>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>

Patch applied.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
index dc32e3c..06e8406 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
@@ -1160,7 +1160,7 @@  static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
 	case PIN_CONFIG_OUTPUT_ENABLE:
 		err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_DIR, &val);
 		if (err)
-			return -EINVAL;
+			return err;
 
 		/* HW takes input mode as zero; output mode as non-zero */
 		if ((val && param == PIN_CONFIG_INPUT_ENABLE) ||
@@ -1184,11 +1184,11 @@  static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
 	case PIN_CONFIG_DRIVE_STRENGTH:
 		err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E4, &val);
 		if (err)
-			return -EINVAL;
+			return err;
 
 		err = mtk_hw_get_value(hw, pin, PINCTRL_PIN_REG_E8, &val2);
 		if (err)
-			return -EINVAL;
+			return err;
 
 		/* 4mA when (e8, e4) = (0, 0); 8mA when (e8, e4) = (0, 1)
 		 * 12mA when (e8, e4) = (1, 0); 16mA when (e8, e4) = (1, 1)
@@ -1203,7 +1203,7 @@  static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
 
 		err = mtk_hw_get_value(hw, pin, reg, &val);
 		if (err)
-			return -EINVAL;
+			return err;
 
 		ret = val;