Received: by 10.223.185.116 with SMTP id b49csp2394233wrg; Mon, 12 Feb 2018 08:52:52 -0800 (PST) X-Google-Smtp-Source: AH8x226yxxHa/nxe9+RJkI2hFUEJnUSPz8W9zCMhWnq+j227s1LkDIqYHeBb+lPdsuPqqtVuoUiv X-Received: by 10.98.199.9 with SMTP id w9mr9668018pfg.97.1518454372421; Mon, 12 Feb 2018 08:52:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518454372; cv=none; d=google.com; s=arc-20160816; b=LNHN/kf/6Ua1wp1AfYOqpGQKi1Li3N5KNrax1srJNDckJW4iHK6S3rLV8SI9nv6M1I yP42on1SLZ+77HHwidYqYtSz+VFEBc+koJxzOn5gd7WufuDVejta5df40CdbDoWXQ9x8 iUkybqZITZAwdpRc244OyRcO691z2Wfu8Ik5j/BNGfsY8c5du/Tf41cDAcGt/6n5uUag r+vh5Ae2FODFPa5wMJmP+JiiD/yAQBAWuwXftx1v2hfEDiX3zQEklFSR4NVv3iXIhAxT e+T27ZGUxIC/+CwnWJAsTgQ1DWAG58gF7NDUM349mwsRpbHiChFctu/wCphr7YqU4Ci9 BQDg== 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:arc-authentication-results; bh=g5a3eT4pAQ6SGlTCP9jKBF2PLB54IrACyuagxOQtLmM=; b=kHXgkV4BTEknlhb6tEvbjpHvX7LFECftej/WZktKnw7ApLM0p0kvC8UPV4fqS5WFjk BN006+nOahyoIzLgJSq3axFmTpyzHcj0QCphafQve/BnkPIYZndWMKtm13AMM1arAWgA HS+ICdRRK7HJ5F16zKQQlW2yHS7yMys/FSm0WLxm+RNgVSTv9b2sZDPatirrSM/67Aif axwN0iANxGXqsU1z+E6zMm37tkJMd1buysS15Irx+Nzfw7uWKEjjqgAEHe4IShOmWdAG UpqSYA4pX2QEa6jScCm0GxDglAJllUg8dbIBXow0dlrBRITQ8BP+nAbqhQYMm0iWDT45 Q2Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T3+jJO9J; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6-v6si6068921plt.72.2018.02.12.08.52.37; Mon, 12 Feb 2018 08:52:52 -0800 (PST) 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=@linaro.org header.s=google header.b=T3+jJO9J; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934021AbeBLNV3 (ORCPT + 99 others); Mon, 12 Feb 2018 08:21:29 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:44084 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935226AbeBLNRq (ORCPT ); Mon, 12 Feb 2018 08:17:46 -0500 Received: by mail-lf0-f67.google.com with SMTP id c188so4485991lfc.11 for ; Mon, 12 Feb 2018 05:17:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g5a3eT4pAQ6SGlTCP9jKBF2PLB54IrACyuagxOQtLmM=; b=T3+jJO9JvHYH96HyIVxJXifibGHk+nROuSgDk2doLY0xK7l3TFW89R9xHHDu44QNHn TPpX/d5y0Tnc07/uj/wmm+FFFXtj8YbeF9X5B2mLUkbf+pPs9cNTanmC0hUpitDLO3ET P1RG4lZWdUnUaf5qiw0+YUvVOREa2uRWQO1tI= 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=g5a3eT4pAQ6SGlTCP9jKBF2PLB54IrACyuagxOQtLmM=; b=QRSgnU+WI5JjgzRpRVrBEmcps2+zHLXL/4JkDFptwKEtDrXAtWn2fJPd10m33gJZpX a6XHfFnnZZMhjfDtBN1nMi1mRImIVKxUKsQxt/1iUnT8aZvc6Pi06L+6kDI+hUCey5/9 A9FU2wviXxqQ9JYcal+fsJPbYrb3/aJM3NebtSe6gPJU+yZ9f2xU4sLYlH6A5WYLTh3i xFnBV0aOCuyeF83rpNopDQqUQa6CpuAOb9JKSC4ckx/+mUmLCILPlo/RZIR+j3HgDZ0o cIbanudUPRkiPN/tS6i/lgiN4YcxWpNjurr8NgSfFnX8zag2LcwbC3WKPHk/9JTR4eVt 1mrg== X-Gm-Message-State: APf1xPA+4ck8PZz5AA/IpFr5aSVBJuvxICYKP+WcWE/oSBStVZGzDXBt YneRCZwq9Bm7+BtBPRNChPgl4g== X-Received: by 10.46.48.1 with SMTP id w1mr7321305ljw.69.1518441465090; Mon, 12 Feb 2018 05:17:45 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:44 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Mikko Perttunen , Laxman Dewangan Subject: [PATCH 07/21] regulator: max8973: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:03 +0100 Message-Id: <20180212131717.27193-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. Cc: Mikko Perttunen Cc: Laxman Dewangan Signed-off-by: Linus Walleij --- drivers/regulator/max8973-regulator.c | 54 +++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index e0c747aa9f85..7cd493ec6315 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -114,7 +115,6 @@ struct max8973_chip { struct regulator_desc desc; struct regmap *regmap; bool enable_external_control; - int enable_gpio; int dvs_gpio; int lru_index[MAX8973_MAX_VOUT_REG]; int curr_vout_val[MAX8973_MAX_VOUT_REG]; @@ -567,7 +567,6 @@ static struct max8973_regulator_platform_data *max8973_parse_dt( pdata->enable_ext_control = of_property_read_bool(np, "maxim,externally-enable"); - pdata->enable_gpio = of_get_named_gpio(np, "maxim,enable-gpio", 0); pdata->dvs_gpio = of_get_named_gpio(np, "maxim,dvs-gpio", 0); ret = of_property_read_u32(np, "maxim,dvs-default-state", &pval); @@ -633,6 +632,8 @@ static int max8973_probe(struct i2c_client *client, struct max8973_chip *max; bool pdata_from_dt = false; unsigned int chip_id; + struct gpio_desc *gpiod; + enum gpiod_flags gflags; int ret; pdata = dev_get_platdata(&client->dev); @@ -647,8 +648,7 @@ static int max8973_probe(struct i2c_client *client, return -EIO; } - if ((pdata->dvs_gpio == -EPROBE_DEFER) || - (pdata->enable_gpio == -EPROBE_DEFER)) + if (pdata->dvs_gpio == -EPROBE_DEFER) return -EPROBE_DEFER; max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); @@ -696,15 +696,11 @@ static int max8973_probe(struct i2c_client *client, max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; - max->enable_gpio = (pdata->enable_gpio) ? pdata->enable_gpio : -EINVAL; max->enable_external_control = pdata->enable_ext_control; max->curr_gpio_val = pdata->dvs_def_state; max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; max->junction_temp_warning = pdata->junction_temp_warning; - if (gpio_is_valid(max->enable_gpio)) - max->enable_external_control = true; - max->lru_index[0] = max->curr_vout_reg; if (gpio_is_valid(max->dvs_gpio)) { @@ -757,27 +753,35 @@ static int max8973_probe(struct i2c_client *client, break; } - if (gpio_is_valid(max->enable_gpio)) { - config.ena_gpio_flags = GPIOF_OUT_INIT_LOW; - if (ridata && (ridata->constraints.always_on || - ridata->constraints.boot_on)) - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio = max->enable_gpio; + if (ridata && (ridata->constraints.always_on || + ridata->constraints.boot_on)) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + gflags); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) { + config.ena_gpiod = gpiod; + max->enable_external_control = true; } + break; case MAX77621: - if (gpio_is_valid(max->enable_gpio)) { - ret = devm_gpio_request_one(&client->dev, - max->enable_gpio, GPIOF_OUT_INIT_HIGH, - "max8973-en-gpio"); - if (ret) { - dev_err(&client->dev, - "gpio_request for gpio %d failed: %d\n", - max->enable_gpio, ret); - return ret; - } - } + /* + * We do not let the core switch this regulator on/off, + * we just leave it on. + */ + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) + max->enable_external_control = true; max->desc.enable_reg = MAX8973_VOUT; max->desc.enable_mask = MAX8973_VOUT_ENABLE; -- 2.14.3