diff mbox

[2/3] pinctrl: qcom-spmi-gpio: Fix input value report

Message ID 1428592717-21706-2-git-send-email-ivan.ivanov@linaro.org (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Ivan T. Ivanov April 9, 2015, 3:18 p.m. UTC
Read input buffer when input is enabled, not when it is
disabled. Also fix interpretation of the pmic_gpio_read()
return code, negative value means an error.

Signed-off-by: Ivan T. Ivanov <ivan.ivanov@linaro.org>
---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--
1.9.1

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

Comments

Bjorn Andersson April 9, 2015, 4:01 p.m. UTC | #1
On Thu 09 Apr 08:18 PDT 2015, Ivan T. Ivanov wrote:

> Read input buffer when input is enabled, not when it is
> disabled. Also fix interpretation of the pmic_gpio_read()
> return code, negative value means an error.
> 
> Signed-off-by: Ivan T. Ivanov <ivan.ivanov@linaro.org>
> ---

>  drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
> index 4b21aac..e8b74c6 100644
> --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
> +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
> @@ -466,12 +466,13 @@ static void pmic_gpio_config_dbg_show(struct pinctrl_dev *pctldev,
>  		seq_puts(s, " ---");
>  	} else {
> 
> -		if (!pad->input_enabled) {
> +		if (pad->input_enabled) {
>  			ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS);
> -			if (!ret) {
> -				ret &= PMIC_MPP_REG_RT_STS_VAL_MASK;
> -				pad->out_value = ret;
> -			}
> +			if (ret < 0)
> +				return;
> +
> +			ret &= PMIC_MPP_REG_RT_STS_VAL_MASK;
> +			pad->out_value = ret;

I'm not too happy on pmic_gpio_read() returning the register value as an
signed int, sorry for not picking on this back when we merged the
driver.

As far as I can see bit 31 is reserved in all registers in the block
though, so there shouldn't be any practical issues with this _today_.

But please consider revising pmic_gpio_read() to take a u32* parameter
for the data instead.

Reviewed-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>

Regards,
Bjorn

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij April 28, 2015, 12:49 p.m. UTC | #2
On Thu, Apr 9, 2015 at 5:18 PM, Ivan T. Ivanov <ivan.ivanov@linaro.org> wrote:

> Read input buffer when input is enabled, not when it is
> disabled. Also fix interpretation of the pmic_gpio_read()
> return code, negative value means an error.
>
> Signed-off-by: Ivan T. Ivanov <ivan.ivanov@linaro.org>

Patch applied for fixes.

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

Patch

diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
index 4b21aac..e8b74c6 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
@@ -466,12 +466,13 @@  static void pmic_gpio_config_dbg_show(struct pinctrl_dev *pctldev,
 		seq_puts(s, " ---");
 	} else {

-		if (!pad->input_enabled) {
+		if (pad->input_enabled) {
 			ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS);
-			if (!ret) {
-				ret &= PMIC_MPP_REG_RT_STS_VAL_MASK;
-				pad->out_value = ret;
-			}
+			if (ret < 0)
+				return;
+
+			ret &= PMIC_MPP_REG_RT_STS_VAL_MASK;
+			pad->out_value = ret;
 		}

 		seq_printf(s, " %-4s", pad->output_enabled ? "out" : "in");