From patchwork Sun Apr 22 23:07:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133931 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368216lji; Sun, 22 Apr 2018 16:10:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ZwV81A+6rTEAFfKJJV7w7uHiJJ2XLqW7Y8A677LT+zxjFsohc/drIrsaUFSeGfe1PL6gj X-Received: by 2002:a17:902:1a6:: with SMTP id b35-v6mr16240587plb.80.1524438614307; Sun, 22 Apr 2018 16:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438614; cv=none; d=google.com; s=arc-20160816; b=XfQMCxYNzVeJn5Sk6MFIjAWdPNkoXqFxgP93DaejXmSmm+DAeB+YZuyxCsIi2+p75X TwG4l3UKTy1+yaJad+Qwp5dbyRgx6mk0WA3Ue0Vontlky1avDAH2/nuCtQh561oE/XQI F+uq2VFkvJCtATe8r/7QZjEIRwPc9Tk88ShPWm1y2flUkKNeMYBMLj+yUZUTuyis+hl1 41yYUc8/a34DUKO2uJ8SXSg//Uh0zuJwJFIqqIqg8Ywli1p6HwqgiE3tW0NxQJKKneJb ymG5gPAU6ygYndNzu8tzRTn5o6reROjY8ePX5H1jzhlKu70Ma0gTE4yWb48bLszDB5JA o5Xw== 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=KUG+Kudzd+krjS0F4R6VelPCLuLbRGv+v/KclaWnu1U=; b=Rl+xMwXiPr/HhO42XCQwoYjJXGCKgC0bQPctSgOm8VZ9wa0uyx/LNjCe/MGmj4BcAS EHbJCB9eyZ5VYNXeLSK2+vbS7yLKkWEfwpyc74xKdEfS23P5zpzxywkWJWZ9DqU1cBTg JqXVVw95fbNrxQ6B8TYXGfuG/AnbGTV8mwm0SonbnNtTeqMP/VgjfaeK5ZvOBkGHvmxe 53QMGjHWNNIv/x0we+ht2EC/EchvvUigjRfqXSPOcWr4oxVJfT5qfNCw2+JSIfeW3Mny baAG2/rc9kDl/X+YYdj+olY4vP9CUaeJmEgJzi10KtynOKZtpzd/aPKFpXiibPItIBSx gAJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FyIauxjI; 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 k10si7616465pgs.304.2018.04.22.16.10.14; Sun, 22 Apr 2018 16:10:14 -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=FyIauxjI; 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 S1753878AbeDVXKI (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:08 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:38328 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753847AbeDVXKE (ORCPT ); Sun, 22 Apr 2018 19:10:04 -0400 Received: by mail-lf0-f67.google.com with SMTP id z130-v6so12234109lff.5 for ; Sun, 22 Apr 2018 16:10:04 -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=KUG+Kudzd+krjS0F4R6VelPCLuLbRGv+v/KclaWnu1U=; b=FyIauxjIHR7t8oHB9HT5OBY2uUw6Seap1Sp3SkK7fUEqO4k9sHtJgQTpnF35SXYhyg 17cyMfC/vcnPvsYrMmB2LbM/3Nh3OMHHN9CuoURiTsD5hXmTmhMarp9jASoE/7gtI9WG wR2iftiMCOuuVlo8fOYvxf1lBd22rG3fBPVGw= 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=KUG+Kudzd+krjS0F4R6VelPCLuLbRGv+v/KclaWnu1U=; b=Ja71ZMCxxLopHIdtij17UWPFh4DVGv9N3kSwYvUERNRb6OAJ3wAEARo6LHMgBPTkbS LbaqcBXuHbUGa8ulbBiil6CS6Tpz86zcllS3G+yBmEU5ByNShfKVDpRYgI6TKYCDn6d5 jqls1TyDGKZRjojzF3lYOP++PaNU0BR2g2GcttnxDP2CEA82drGMOuQf/QWzhc2H0yC7 x5DZjOsp2O+pLRPFfpWEMN+UG/PdS2c5XNMrr/lF4WHtD9jANV1RLHP4tJF/o5cYuqTE 1UyMLiQkbNM1zypDSHqsGF+slXW9IZNPYw24uFkSFfK18ssfRIdKUlPcuYAEpdtjGpWk Nn6w== X-Gm-Message-State: ALQs6tDYGCz0F6ZWuNyAxiIjEfaSP59eJiqcSb/TOolAfdjg5oEpZvvn +u7M6wgcen7elXzREVNgks2Udg== X-Received: by 2002:a19:4318:: with SMTP id q24-v6mr7217228lfa.22.1524438603121; Sun, 22 Apr 2018 16:10:03 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id r25sm2036291ljc.8.2018.04.22.16.10.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:02 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 06/18 v2] regulator: lm363x: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:30 +0200 Message-Id: <20180422230742.3729-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180422230742.3729-1-linus.walleij@linaro.org> References: <20180422230742.3729-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 v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/lm363x-regulator.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.14.3 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,