Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3507715imm; Thu, 17 May 2018 09:49:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqhFkKeHvi+aOYlZsWtyPwQ+4RuG41d2g4wRpcSK0AYarUWD/q7U5I/EeGl8hOxxJK37NI1 X-Received: by 2002:a17:902:a616:: with SMTP id u22-v6mr6041404plq.186.1526575788664; Thu, 17 May 2018 09:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526575788; cv=none; d=google.com; s=arc-20160816; b=0SWhIOnM42RRotvzItbChKm4W0FjL1dloKkWKFrQF1i5bpP/p8uMLWWCQkfDvyz7SV Npo+s6vBlMpSXEFeAwSpW3osGuI2DbgAppGKSmeLmhxu3SgYudvLDbVAhEN1cJBV0jfR bXLI7Oekzl02e10NFtD2otJHv7+qLsLl/QdSZ7khzJmLg5YT4uQSUv24vcrPA6wTd2k5 CmHjP9UzQgd0gYBTM17cuFgFx0Myecy/lBwIaupiHuigLxAh3qTg9l89MC+Ut4u6acNL H6kxetySKGO8vS7Z9KErbsXswUj+yjxpa7tIb2XFh783Tdb8XY8eDfwqZEzxhfRjlffF CF2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=bSaS7SHJN+2mY2Ur6G7ATNIRvpfeFgdm4EbXpAEi2/k=; b=R4MSYGnfdAUpTFvzwPSiS/926E7JZpMmrTa0rF/4RDLLwZJaYkKlWoyhs2QlJZYaPk W+9gaMH/eBMeWawEbNh7f1l2kYKeNVCgfz37CjklhQI9Y+xk7ZxOJDGu/qRH/DBFqmvV u+2Nic+jFG8w9RnXMOsYpqj9ZL5+yI5BsxQxM8hkXXgUgJ1T8cPK9kPAbrsbIWr/VG3z 5gfnalPJQAPnbc4ufCbnkNZ3s4BhcpomYdOPXAo6xtQGgL8LeiO3gzhS97mAmRjL8hAn DjN06xVc8U9+77K2ERtX7/KWWu4ZILrQmd0a/2V79gxX1Y3GfPpoka/XyMq2Q/cwcWNy FJ9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=oCgDngBc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b37-v6si5340983plb.377.2018.05.17.09.49.34; Thu, 17 May 2018 09:49:48 -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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=oCgDngBc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752065AbeEQQsn (ORCPT + 99 others); Thu, 17 May 2018 12:48:43 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:53370 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752464AbeEQQll (ORCPT ); Thu, 17 May 2018 12:41:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=bSaS7SHJN+2mY2Ur6G7ATNIRvpfeFgdm4EbXpAEi2/k=; b=oCgDngBccwbR /+PrCP5gTvZ7SuBN6PmXjMCeTEq+aU8YdY1ooPYussDO8jftyz+YB8Wai8v4BSVKiuECk4ESe98SJ wkT1K9JgZdxtY+XrP9xqMhN1j2DQdpqgCNYCb/tcWZThhRDrFSwarlxpfUt3+dUvkkopEILW64GYu 1tOZA=; Received: from [37.205.61.206] (helo=finisterre.ee.mobilebroadband) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fJLyE-00014E-HZ; Thu, 17 May 2018 16:41:38 +0000 Received: by finisterre.ee.mobilebroadband (Postfix, from userid 1000) id 98F9344007E; Thu, 17 May 2018 17:41:35 +0100 (BST) From: Mark Brown To: Linus Walleij Cc: Krzysztof Kozlowski , Mark Brown , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Krzysztof Kozlowski , Sangbeom Kim , Chanwoo Choi , linux-kernel@vger.kernel.org Subject: Applied "regulator: s2mps11: Pass descriptor instead of GPIO number" to the regulator tree In-Reply-To: <20180212131717.27193-14-linus.walleij@linaro.org> Message-Id: <20180517164135.98F9344007E@finisterre.ee.mobilebroadband> Date: Thu, 17 May 2018 17:41:35 +0100 (BST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch regulator: s2mps11: Pass descriptor instead of GPIO number has been applied to the regulator tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 0369e02b75e6381f892e3bd45f1d8d6330d855fb Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 14 May 2018 10:06:31 +0200 Subject: [PATCH] regulator: s2mps11: Pass descriptor instead of GPIO number Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Signed-off-by: Linus Walleij Reviewed-by: Krzysztof Kozlowski Tested-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/s2mps11.c | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 7726b874e539..9a1dca26362e 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -57,7 +56,7 @@ struct s2mps11_info { * Array (size: number of regulators) with GPIO-s for external * sleep control. */ - int *ext_control_gpio; + struct gpio_desc **ext_control_gpiod; }; static int get_ramp_delay(int ramp_delay) @@ -524,7 +523,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev) case S2MPS14X: if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) val = S2MPS14_ENABLE_SUSPEND; - else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) + else if (s2mps11->ext_control_gpiod[rdev_get_id(rdev)]) val = S2MPS14_ENABLE_EXT_CONTROL; else val = rdev->desc->enable_mask; @@ -818,7 +817,7 @@ static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11, static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) { - int *gpio = s2mps11->ext_control_gpio; + struct gpio_desc **gpio = s2mps11->ext_control_gpiod; unsigned int i; unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11, S2MPS14_LDO12 }; @@ -829,11 +828,20 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, if (!rdata[reg].init_data || !rdata[reg].of_node) continue; - gpio[reg] = of_get_named_gpio(rdata[reg].of_node, - "samsung,ext-control-gpios", 0); - if (gpio_is_valid(gpio[reg])) - dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n", - gpio[reg], reg, rdata[reg].name); + gpio[reg] = devm_gpiod_get_from_of_node(&pdev->dev, + rdata[reg].of_node, + "samsung,ext-control-gpios", + 0, + GPIOD_OUT_HIGH, + "s2mps11-LDO"); + if (IS_ERR(gpio[reg])) { + dev_err(&pdev->dev, "Failed to get control GPIO for %d/%s\n", + reg, rdata[reg].name); + continue; + } + if (gpio[reg]) + dev_dbg(&pdev->dev, "Using GPIO for ext-control over %d/%s\n", + reg, rdata[reg].name); } } @@ -1139,17 +1147,11 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) return -EINVAL; } - s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, - sizeof(*s2mps11->ext_control_gpio) * rdev_num, + s2mps11->ext_control_gpiod = devm_kmalloc(&pdev->dev, + sizeof(*s2mps11->ext_control_gpiod) * rdev_num, GFP_KERNEL); - if (!s2mps11->ext_control_gpio) + if (!s2mps11->ext_control_gpiod) return -ENOMEM; - /* - * 0 is a valid GPIO so initialize all GPIO-s to negative value - * to indicate that external control won't be used for this regulator. - */ - for (i = 0; i < rdev_num; i++) - s2mps11->ext_control_gpio[i] = -EINVAL; if (!iodev->dev->of_node) { if (iodev->pdata) { @@ -1179,8 +1181,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.dev = &pdev->dev; config.regmap = iodev->regmap_pmic; config.driver_data = s2mps11; - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio_initialized = true; for (i = 0; i < rdev_num; i++) { struct regulator_dev *regulator; @@ -1191,7 +1191,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.init_data = rdata[i].init_data; config.of_node = rdata[i].of_node; } - config.ena_gpio = s2mps11->ext_control_gpio[i]; + config.ena_gpiod = s2mps11->ext_control_gpiod[i]; regulator = devm_regulator_register(&pdev->dev, ®ulators[i], &config); @@ -1202,7 +1202,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) goto out; } - if (gpio_is_valid(s2mps11->ext_control_gpio[i])) { + if (s2mps11->ext_control_gpiod[i]) { ret = s2mps14_pmic_enable_ext_control(s2mps11, regulator); if (ret < 0) { -- 2.17.0