From patchwork Mon May 14 08:06:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135685 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1449958lji; Mon, 14 May 2018 01:18:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoor2kc5515WB4EwZ6JiyKb3O2mwVVvkYgy9vQMPh7JG8kt+VoQa1tnDXLdsXNEiMQLQTXc X-Received: by 2002:a17:902:6903:: with SMTP id j3-v6mr8855870plk.313.1526285884473; Mon, 14 May 2018 01:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285884; cv=none; d=google.com; s=arc-20160816; b=dNbt7HJvVu65c7bcf+dHRw4M1FnQYJjTSH92GSspoEGeabGhv674K5YKDVOxVFL4CI rllttni991+MP5ijL15p0OSXpcdXLlO2mPW8FiWBRoWPBXnVMO7NhOvkZSkzZCJCNCu+ 7FyPxOU7kF+Em4WX2mf/ceU4TOKtMAtvgBpGGzFn2Cx7DBbp7xfdZCK0NnyRPTJUqiIp EEfxRYd9MMpXRh6Dlw1eORgregzo75nbcxEHDpmZQYRSSrxXhEUkmi/je40oOuutTfbx J5EruqWlj1uESX7AjpfLANm2nIQ5Q5QPZP1vMYYRzRmGv6SHO/QoVg2dnu7HHGR3m3SZ S6og== 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=a/EcC5ESXkXYLgOphdHAIg+iX/TpZMtvZ9sS2YELV6s=; b=gRW6+GiEJD7uthpKkvugPSe7gAI2Z6VEisUavrv/3Evxm+GLxE0xBinlhQ4E4H6udG fWIQh3HQiZsAU3Pf063n+IoGKg0gS2Ojzqb1ykxN0FwBK9KtNoKfbhl+guQU4thsFF+A W3jj3j7zrgWlsinfOyBZoJPyLQhgm/3WzmuK3Euz8JMHnung7ql5gIA33X+LkbFLXgOW DInWjrhD+buEoTMRv1UYBkLulvNXKovzBWSVx2am8uf4utc9dGmMVZ6ZIOPY7FY4kiXd C4jX1p3peIhJzmQf7W46oYOQKW7GWbZXwcihUGcUJEaDqsMiuYTJFeubB/lZ7DcnLWQt 27sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CsydSttD; 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 j7-v6si9788422plk.506.2018.05.14.01.18.04; Mon, 14 May 2018 01:18:04 -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=@linaro.org header.s=google header.b=CsydSttD; 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 S1752659AbeENISA (ORCPT + 29 others); Mon, 14 May 2018 04:18:00 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36035 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbeENIHB (ORCPT ); Mon, 14 May 2018 04:07:01 -0400 Received: by mail-lf0-f66.google.com with SMTP id t129-v6so16536245lff.3 for ; Mon, 14 May 2018 01:07:00 -0700 (PDT) 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=a/EcC5ESXkXYLgOphdHAIg+iX/TpZMtvZ9sS2YELV6s=; b=CsydSttD6Mq5qne6u5hZ3PiW1t4vhQzufJp6+kJMjpQYvRKG4jUv+yo6Jnhw6nzZDu 9l0HJR6D9d5IvMqjVSPqL9fs1LhqAsvHddU4Dxs4mk71MNZJK08f6g3MCsSEXLh4sX0W xfm7IB3LS/HTJpinP6c6M8yPrshxaBfB51X/4= 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=a/EcC5ESXkXYLgOphdHAIg+iX/TpZMtvZ9sS2YELV6s=; b=K6JkbJ3B6h0V5toje1RuNXkcQOM6z8mN8a3mdFk0c0DoH2uJVsQRZMNpeBDMXWF3nt K82zIim0wS4ciRwl7b0mqJ67IP+A3JbkpK+uTavDE9lo7Ua7jCB4WBYwqXAGl82wELoa B8R0j2QLeaYIR+AwwGW5JE0aPUs6H0WRaMxZ9hdBfQylpyHe2IgbXtwul0mVeIUVODOt 7VY+e3FAWs2/Yr+NzObIzYWWg1ssDFkHLiZXLDZt3or+sgUeMSrPySVz326PidJkaGbw RxjlNorTEkEL1LqVaq9He966jqBWxIBoB4/YPhdA9ycQ99H64vZSmsvjoXXMe5hGt7LW aBZQ== X-Gm-Message-State: ALKqPwdV8X8ObwgkdbdwC/sAx1ESNw9vQeAGWUBJ7qCUTwJ46e7odAOo Jsl/xS4rt7aten9RhXhWEn7+Aw== X-Received: by 2002:a19:1186:: with SMTP id 6-v6mr8206963lfr.134.1526285220180; Mon, 14 May 2018 01:07:00 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.06.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:06:59 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 06/19 v3] regulator: lm363x: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:27 +0200 Message-Id: <20180514080640.12515-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-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_index_optional() call. Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/lm363x-regulator.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.17.0 diff --git a/drivers/regulator/lm363x-regulator.c b/drivers/regulator/lm363x-regulator.c index ce5f7d9ad475..b615a413ca9f 100644 --- a/drivers/regulator/lm363x-regulator.c +++ b/drivers/regulator/lm363x-regulator.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -219,7 +219,7 @@ static const struct regulator_desc lm363x_regulator_desc[] = { }, }; -static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) +static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, int id) { /* * Check LCM_EN1/2_GPIO is configured. @@ -227,11 +227,11 @@ static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) */ switch (id) { case LM3632_LDO_POS: - return of_get_named_gpio(np, "enable-gpios", 0); + return devm_gpiod_get_index_optional(dev, "enable", 0, GPIOD_OUT_LOW); case LM3632_LDO_NEG: - return of_get_named_gpio(np, "enable-gpios", 1); + return devm_gpiod_get_index_optional(dev, "enable", 1, GPIOD_OUT_LOW); default: - return -EINVAL; + return NULL; } } @@ -243,7 +243,8 @@ static int lm363x_regulator_probe(struct platform_device *pdev) struct regulator_dev *rdev; struct device *dev = &pdev->dev; int id = pdev->id; - int ret, ena_gpio; + struct gpio_desc *gpiod; + int ret; cfg.dev = dev; cfg.regmap = regmap; @@ -252,10 +253,9 @@ static int lm363x_regulator_probe(struct platform_device *pdev) * LM3632 LDOs can be controlled by external pin. * Register update is required if the pin is used. */ - ena_gpio = lm363x_regulator_of_get_enable_gpio(dev->of_node, id); - if (gpio_is_valid(ena_gpio)) { - cfg.ena_gpio = ena_gpio; - cfg.ena_gpio_flags = GPIOF_OUT_INIT_LOW; + gpiod = lm363x_regulator_of_get_enable_gpio(dev, id); + if (gpiod) { + cfg.ena_gpiod = gpiod; ret = regmap_update_bits(regmap, LM3632_REG_BIAS_CONFIG, LM3632_EXT_EN_MASK,