Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp174305imd; Wed, 31 Oct 2018 16:49:07 -0700 (PDT) X-Google-Smtp-Source: AJdET5ftQ9tMFVDekCPuY59kSQy29qsFkwQA1txUdSoZS/JKR8UoI7tukJRcb9XnfeF2T+gBvROB X-Received: by 2002:a63:d444:: with SMTP id i4-v6mr4990397pgj.194.1541029747048; Wed, 31 Oct 2018 16:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029747; cv=none; d=google.com; s=arc-20160816; b=EecTEMi/+JqtqkypqdIh+/cVtWbtMezAnltNrWeDCGIXZo0Cf/4sMp9Jj94kPG/Gpp 6uqwyfq34Txvx233kUh6T5H1njXuY8LQOlSTe2UsCkidHxEp3en5CDTeF1wIKMOIXopq LvM6t6WgVcAtNAHblDKZC6k6ECcSCWY7KVUlCrSS6k6oA8zLw1djy27+2uBdbtNZu/xr SKkzyJ3V++QwX7mPxFLsl+BSaVOcqmsQOTm0Ah4hQNitq/lmJRKqSoqpDrhsW55qM6Lf OMQS3t/yTPzWbDxOSmYdKP/1oIjIjGh0qcGlmxpa6xL43TWzriF7W6QSsa1fe5+s2bE0 guGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=aSCOn4/o/tjBvnSGq7cdneZs3vjFC/yqnJcI9Okt/jY=; b=Zq0ExBkeTLIqUNrg99ZQs1T6/ZalH1mlg4IulDBIxX0KDuTE8m7Plbri5qejJRZZ8r /+Q5Iflc6vjlovWk9YXbjIVmOqD8dr3FgFe5Yrlt8qFwxGG5IryvXDQBXFwMIHi/+Vnb bS+5gHoeUAfB7cOMoTY9faoRCorneGTgxNm1R8QcL8yNIo/Jr2OkkJJAa+H1eNWANfpX aWZnH7jbRJ0bJx8+ceMH8pgV5kvgc/b4j/HNs9zhjPOabu+QnLdGsc/30iD/Tn3wE299 mjRQhoJ/H/LhRpwcSBdKVxSDj9rSHCsbXU7gtbD6oxlMiOadfpVot4LS8uHsw7GyFYj5 ldmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="o7CM/tdH"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j193si8225484pge.332.2018.10.31.16.48.52; Wed, 31 Oct 2018 16:49:07 -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; dkim=pass header.i=@kernel.org header.s=default header.b="o7CM/tdH"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728754AbeKAIsw (ORCPT + 99 others); Thu, 1 Nov 2018 04:48:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:54226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728412AbeKAIGz (ORCPT ); Thu, 1 Nov 2018 04:06:55 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B2DE620664; Wed, 31 Oct 2018 23:06:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027204; bh=VX2FgP8zSlWA7Xz503DcJIJbzzrre9LO4e0nlr132H8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o7CM/tdHmRDNNYoDwUFuuRtxI6/r+osnxSYnHi5NL7x3I4x2+l3Yly25vNb0LbSBw E7QlkVero7ERZ4DVnVT7lJ6P3nEw/LiWtUeehTgkpHIAj/0p7jenz2m92ZR354oBwo YdTkpHjkfsbtt8sARBdUCdedSXgMCf5vhUHxv7es= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Douglas Anderson , Linus Walleij , Sasha Levin Subject: [PATCH AUTOSEL 4.19 067/146] pinctrl: spmi-mpp: Fix pmic_mpp_config_get() to be compliant Date: Wed, 31 Oct 2018 19:04:22 -0400 Message-Id: <20181031230541.28822-67-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Douglas Anderson [ Upstream commit 0d5b476f8f57fcb06c45fe27681ac47254f63fd2 ] If you look at "pinconf-groups" in debugfs for ssbi-mpp you'll notice it looks like nonsense. The problem is fairly well described in commit 1cf86bc21257 ("pinctrl: qcom: spmi-gpio: Fix pmic_gpio_config_get() to be compliant") and commit 05e0c828955c ("pinctrl: msm: Fix msm_config_group_get() to be compliant"), but it was pointed out that ssbi-mpp has the same problem. Let's fix it there too. NOTE: in case it's helpful to someone reading this, the way to tell whether to do the -EINVAL or not is to look at the PCONFDUMP for a given attribute. If the last element (has_arg) is false then you need to do the -EINVAL trick. ALSO NOTE: it seems unlikely that the values returned when we try to get PIN_CONFIG_BIAS_PULL_UP will actually be printed since "has_arg" is false for that one, but I guess it's still fine to return different values so I kept doing that. It seems like another driver (ssbi-gpio) uses a custom attribute (PM8XXX_QCOM_PULL_UP_STRENGTH) for something similar so maybe a future change should do that here too. Fixes: cfb24f6ebd38 ("pinctrl: Qualcomm SPMI PMIC MPP pin controller driver") Signed-off-by: Douglas Anderson Reviewed-by: Stephen Boyd Reviewed-by: Bjorn Andersson Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c index 7577f133d326..ac251c62bc66 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c @@ -345,13 +345,12 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev, switch (param) { case PIN_CONFIG_BIAS_DISABLE: - arg = pad->pullup == PMIC_MPP_PULL_UP_OPEN; + if (pad->pullup != PMIC_MPP_PULL_UP_OPEN) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_BIAS_PULL_UP: switch (pad->pullup) { - case PMIC_MPP_PULL_UP_OPEN: - arg = 0; - break; case PMIC_MPP_PULL_UP_0P6KOHM: arg = 600; break; @@ -366,13 +365,17 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev, } 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; @@ -384,7 +387,9 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev, arg = pad->amux_input; break; case PMIC_MPP_CONF_PAIRED: - arg = pad->paired; + if (!pad->paired) + return -EINVAL; + arg = 1; break; case PIN_CONFIG_DRIVE_STRENGTH: arg = pad->drive_strength; -- 2.17.1