Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2515607imm; Mon, 24 Sep 2018 05:46:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdayXmifLFZY2CtCb5nPeU+/vquR/kJknaUwrowZPXGyRbhu0c8vetqmutDuJcoh+2ajWJjo X-Received: by 2002:a62:59d5:: with SMTP id k82-v6mr10103534pfj.143.1537793202545; Mon, 24 Sep 2018 05:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537793202; cv=none; d=google.com; s=arc-20160816; b=fm/N06RVOyKj34j/HRZLwDMrVdt607M+ViflbBa6dloxpzbN5F/gSkYhsp335pcvRr tYR9Zz8/tz5e9H7OckJXvp6YL8rpeZkGQyaoZA/iksMxyWCt37sObY91OujCwxRUhyb/ MfX0W8HeUiVtygIfPZARrU6FmOGuYnLcQoiqYtYp/vk9h4yRXsuc66VVvOL19IakdKai BvBORZsmOtezpCXLN1KgxxeVROxUgQTkAHVDnB4jLuSld0BaWjIRerJi++02RqZDL0fL RdE8EFXW7TcRruSfYz8KLjoi3iCAf2C/BSLoZiYsn9beSg8HZs/oHVZzJpNebIAF2umY gR2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=m1H/o+bldqDX2RXbSjb/yU6SK9SyXNgovQHpb61ySWs=; b=e2nYpebb4UJJrR14lcWQhWomSiDlMpFcyvCZf6UdmkKJZL3PykMVjY8g/8CGvrm4aG VQ4Kz78L0xJBwcTHzIBGmMmU21fZu8tJredYCoeZCjmwdezR3A74jpXKaJPyTAxMRN6r F8kPH+QV9eo3+oORxS9ZHV/q4o2dk6Hxz/ai0Oiu/obc+dlsoJ+gbWC/Vtit0wci6mgA lg6zbyjc3rXTFwmtUyTITjISiuBbbgzwTS7hSoc4hJSHcZl47Ql8xDtKbHrqwZkaKDyH XDqaUD3AxhrzbB4AMucTHpgGKUNCWfVgnNNOuQ/wVed2TVuVHYto4i6VafJmdcGmNjl0 syig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9-v6si33480355pgf.380.2018.09.24.05.46.27; Mon, 24 Sep 2018 05:46:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389344AbeIXSr1 (ORCPT + 99 others); Mon, 24 Sep 2018 14:47:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59788 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730081AbeIXSr1 (ORCPT ); Mon, 24 Sep 2018 14:47:27 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1C708109A; Mon, 24 Sep 2018 12:45:26 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , Linus Walleij , Sasha Levin Subject: [PATCH 4.18 232/235] pinctrl: qcom: spmi-gpio: Fix pmic_gpio_config_get() to be compliant Date: Mon, 24 Sep 2018 13:53:38 +0200 Message-Id: <20180924113126.003052623@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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, input 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 "=" instead of "==" 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 driver") Signed-off-by: Douglas Anderson Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 32 +++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) --- 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 p switch (param) { case PIN_CONFIG_DRIVE_PUSH_PULL: - arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_CMOS; + if (pad->buffer_type != PMIC_GPIO_OUT_BUF_CMOS) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_DRIVE_OPEN_DRAIN: - arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS; + if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_DRIVE_OPEN_SOURCE: - arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS; + if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_BIAS_PULL_DOWN: - arg = pad->pullup == PMIC_GPIO_PULL_DOWN; + if (pad->pullup != PMIC_GPIO_PULL_DOWN) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_BIAS_DISABLE: - arg = pad->pullup = PMIC_GPIO_PULL_DISABLE; + if (pad->pullup != PMIC_GPIO_PULL_DISABLE) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_BIAS_PULL_UP: - arg = pad->pullup == PMIC_GPIO_PULL_UP_30; + if (pad->pullup != PMIC_GPIO_PULL_UP_30) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: - arg = !pad->is_enabled; + if (pad->is_enabled) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_POWER_SOURCE: arg = pad->power_source; break; case PIN_CONFIG_INPUT_ENABLE: - arg = pad->input_enabled; + if (!pad->input_enabled) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_OUTPUT: arg = pad->out_value;