From patchwork Mon Feb 12 13:17:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 872062 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LYDZuGHD"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zg5s03S4Bz9ryT for ; Tue, 13 Feb 2018 00:20:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935270AbeBLNRy (ORCPT ); Mon, 12 Feb 2018 08:17:54 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:45193 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935267AbeBLNRv (ORCPT ); Mon, 12 Feb 2018 08:17:51 -0500 Received: by mail-lf0-f68.google.com with SMTP id x196so20328277lfd.12 for ; Mon, 12 Feb 2018 05:17:50 -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=tqXpUwKG6hUpLmNnwuDZ8Xb8+RGj4kJMQ0JC7BLEzCw=; b=LYDZuGHDpqpwvqZZpV2OaM+7xSu5HBjTglqbgpoxcVRe70ctxh4PzInrE2eOp7nSmz Oc5OOZQofniAT3HMP8ZcEgx0t7P35DBsdSvZUXNs9/8d7YvoEg0FZIrP8CAg2QQfhSlT RV4BPhbuxDTMkGe1clxyNPYcDwvYrgXWjWgUg= 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=tqXpUwKG6hUpLmNnwuDZ8Xb8+RGj4kJMQ0JC7BLEzCw=; b=Hn0JO1WsR7K7PAlxQpv4rHnVkSOP2hSQcuxmkmd8VgP/DdWZLCeR7XVbM9UkowJJ8/ 2yS7HX3KyZoS73fllvml1eK84cU2drxn5nJ8K3hEBdjHmNa2POYEL3L4cWcspqkWuG9N qFopinefdMxU2dD44Bi2iwlpki0GN2K07NOt2NWOc9XvnK/U9x2+kfHRZnEOpRW4G4oJ 9I2nElhlvwiqwJf5bnLkU9MV3WIEtIqfPT4QPh2OWVQbVW4kXplpMPCk6K4QtPH9YgZA KoNnWSopn8nI2ogGpKyH0G7jRiF2TYDXl1vFVkZpZGb16D7SBIjh83AA5/A/9FtaWwMc fLWQ== X-Gm-Message-State: APf1xPBHsDjlGCd3tDrsV3SxhOUMDHQW08L3ysvtw5ekmENI5aRc0M79 2LM9uLyjo/oCELB0SogNq1NUpw== X-Google-Smtp-Source: AH8x224tFP4tO/n7ysJsk0v+RXFz7mGVgwYOWxoWmgTsrBdGPGQlZQyAfIBSZJ2tndk64IvBcF0OJw== X-Received: by 10.25.196.9 with SMTP id u9mr2925309lff.108.1518441469836; Mon, 12 Feb 2018 05:17:49 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:49 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Milo Kim Subject: [PATCH 09/21] regulator: lm363x: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:05 +0100 Message-Id: <20180212131717.27193-10-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Instead of passing a global GPIO number, pass a descriptor looked up with the standard devm_gpiod_get_index_optional() call. Cc: Milo Kim Signed-off-by: Linus Walleij --- drivers/regulator/lm363x-regulator.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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,