From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam01on0098.outbound.protection.outlook.com ([104.47.32.98]:58848 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728647AbeIOGvD (ORCPT ); Sat, 15 Sep 2018 02:51:03 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Douglas Anderson , Linus Walleij , Sasha Levin Subject: [PATCH AUTOSEL 4.14 56/57] pinctrl: qcom: spmi-gpio: Fix pmic_gpio_config_get() to be compliant Date: Sat, 15 Sep 2018 01:33:04 +0000 Message-ID: <20180915013223.179909-56-alexander.levin@microsoft.com> References: <20180915013223.179909-1-alexander.levin@microsoft.com> In-Reply-To: <20180915013223.179909-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Douglas Anderson [ Upstream commit 1cf86bc21257a330e3af51f2a4e885f1a705f6a5 ] If you do this on an sdm845 board: grep "" /sys/kernel/debug/pinctrl/*spmi:pmic*/pinconf-groups ...it looks like nonsense. For every pin you see listed: input bias disabled, input bias high impedance, input bias pull down, inp= ut bias pull up, ... That's because pmic_gpio_config_get() isn't complying with the rules that pinconf_generic_dump_one() expects. Specifically for boolean parameters (anything with a "struct pin_config_item" where has_arg is false) the function expects that the function should return its value not through the "config" parameter but should return "0" if the value is set and "-EINVAL" if the value isn't set. Let's fix this. >>From a quick sample of other pinctrl drivers, it appears to be tradition to also return 1 through the config parameter for these boolean parameters when they exist. I'm not one to knock tradition, so I'll follow tradition and return 1 in these cases. While I'm at it, I'll also continue searching for four leaf clovers, kocking on wood three times, and trying not to break mirrors. NOTE: This also fixes an apparent typo for reading PIN_CONFIG_BIAS_DISABLE where the old driver was accidentally using "=3D" instead of "=3D=3D" and thus was setting some internal state when you tried to query PIN_CONFIG_BIAS_DISABLE. Oops. Fixes: eadff3024472 ("pinctrl: Qualcomm SPMI PMIC GPIO pin controller drive= r") Signed-off-by: Douglas Anderson Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 32 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qco= m/pinctrl-spmi-gpio.c index c2c0bab04257..22aaf4375fac 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c @@ -390,31 +390,47 @@ static int pmic_gpio_config_get(struct pinctrl_dev *p= ctldev, =20 switch (param) { case PIN_CONFIG_DRIVE_PUSH_PULL: - arg =3D pad->buffer_type =3D=3D PMIC_GPIO_OUT_BUF_CMOS; + if (pad->buffer_type !=3D PMIC_GPIO_OUT_BUF_CMOS) + return -EINVAL; + arg =3D 1; break; case PIN_CONFIG_DRIVE_OPEN_DRAIN: - arg =3D pad->buffer_type =3D=3D PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS; + if (pad->buffer_type !=3D PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS) + return -EINVAL; + arg =3D 1; break; case PIN_CONFIG_DRIVE_OPEN_SOURCE: - arg =3D pad->buffer_type =3D=3D PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS; + if (pad->buffer_type !=3D PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS) + return -EINVAL; + arg =3D 1; break; case PIN_CONFIG_BIAS_PULL_DOWN: - arg =3D pad->pullup =3D=3D PMIC_GPIO_PULL_DOWN; + if (pad->pullup !=3D PMIC_GPIO_PULL_DOWN) + return -EINVAL; + arg =3D 1; break; case PIN_CONFIG_BIAS_DISABLE: - arg =3D pad->pullup =3D PMIC_GPIO_PULL_DISABLE; + if (pad->pullup !=3D PMIC_GPIO_PULL_DISABLE) + return -EINVAL; + arg =3D 1; break; case PIN_CONFIG_BIAS_PULL_UP: - arg =3D pad->pullup =3D=3D PMIC_GPIO_PULL_UP_30; + if (pad->pullup !=3D PMIC_GPIO_PULL_UP_30) + return -EINVAL; + arg =3D 1; break; case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: - arg =3D !pad->is_enabled; + if (pad->is_enabled) + return -EINVAL; + arg =3D 1; break; case PIN_CONFIG_POWER_SOURCE: arg =3D pad->power_source; break; case PIN_CONFIG_INPUT_ENABLE: - arg =3D pad->input_enabled; + if (!pad->input_enabled) + return -EINVAL; + arg =3D 1; break; case PIN_CONFIG_OUTPUT: arg =3D pad->out_value; --=20 2.17.1