From patchwork Mon Jul 2 22:59:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 938272 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="lPZqqXoy"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41KN4w47hYz9s2g for ; Tue, 3 Jul 2018 09:00:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932765AbeGBXAO (ORCPT ); Mon, 2 Jul 2018 19:00:14 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:45890 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932730AbeGBXAH (ORCPT ); Mon, 2 Jul 2018 19:00:07 -0400 Received: by mail-pl0-f66.google.com with SMTP id bi1-v6so16947plb.12 for ; Mon, 02 Jul 2018 16:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fb3Fbm94eGdLAvRXZKI+IDFsdV4vr4z71X0awRp6s3U=; b=lPZqqXoyf5BAcYF/S5JmRBSS47BvUis1KQmRFzveUWrxSaBk6xvA/C8IsUSM76U6m1 BwLjLneXNNAgOblZAU3qQ2A0chTAl+kPWjbxYq89t9t0MqXV0JKQR1M/7/j6Smut/izs 85eVFJxZIRumhAFy010jW9uV6AvsJQrG7IrNg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Fb3Fbm94eGdLAvRXZKI+IDFsdV4vr4z71X0awRp6s3U=; b=WmFqKkEcf3bYDLCEidlG2TD7u4n9gjSv+smJCUTe1RIZ75AFpLt7lx7fBwTlMyr4HV izpHzV5/JuxjcqlQeoO38Puql4HfnKAlChbv/qu5rK1gf9QIEq3dEb3Mji63UwO86tmm XauWGpUAJRFeJnsPg/Ksc0NhiyyoPwLnPE3sAfFvwjAel114odnjo/gsETvWyIRvZnar A4YxQjMW19z4AxPBip6wpCjcPJfRPvb+/xLD3LVi5CQDUqEemN6RpCrP9L8exzwIzpva 7m4h/3fyTZBDt2gSxYEBxC9YDD9r1SdZS7bAs8AmQJEV7OhKVwSa+OkafftQYHGZUFU1 /mFA== X-Gm-Message-State: APt69E0PR+3yS7NCouBH66/W3qRouZl11JplSwPkC2/v/xfVEaAVq8cf A2vc1jxHng5O6ZotVZdyrYalQA== X-Google-Smtp-Source: ADUXVKLoIaIUZH+A9Y0iVPP3FSKIX64a0DaSdlqNxgzL3qfURr6QlEbdC4TeDpg32Q99FCUDl9AAxw== X-Received: by 2002:a17:902:1e4:: with SMTP id b91-v6mr27600297plb.155.1530572406178; Mon, 02 Jul 2018 16:00:06 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:0:1000:1501:38e4:86fe:ec0c:4007]) by smtp.gmail.com with ESMTPSA id v66-v6sm18878027pfb.84.2018.07.02.16.00.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 16:00:05 -0700 (PDT) From: Douglas Anderson To: Bjorn Andersson , Linus Walleij Cc: iivanov@mm-sol.com, swboyd@chromium.org, Douglas Anderson , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 3/3] pinctrl: qcom: spmi-gpio: Fix pmic_gpio_config_get() to be compliant Date: Mon, 2 Jul 2018 15:59:39 -0700 Message-Id: <20180702225939.109169-3-dianders@chromium.org> X-Mailer: git-send-email 2.18.0.399.gad0ab374a1-goog In-Reply-To: <20180702225939.109169-1-dianders@chromium.org> References: <20180702225939.109169-1-dianders@chromium.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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 --- 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/qcom/pinctrl-spmi-gpio.c index 3e66e0d10010..cf82db78e69e 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 *pctldev, 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;