Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5036522imu; Sat, 1 Dec 2018 07:56:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xc2CwD02kZ+UpAw8nF6X6Lu109vyH8SIAqK6TbcsiYUVObjIfL4Jwk0VoT3Ml+WsfkErzY X-Received: by 2002:a62:6ec8:: with SMTP id j191mr9689389pfc.198.1543679807014; Sat, 01 Dec 2018 07:56:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679806; cv=none; d=google.com; s=arc-20160816; b=Vs2Y53Bg/d8Xs3kqA4EQ4R9P3L0NQzr3Aqq37Pndo2WCv1Lsw+fQUAQEXDWlwtgBQn StrTBhyg2r005UMMe4Bu5sHEOCsNTpB1nReClD/4amcQLOLn1dF71lUK6qXV8h7SgHf7 JjAhSHfldECr7qL3VRuOXLMYy1tID4asI5ytvuLWbd6lMY3L6lhVIoOFMEV/pOsH1PsU hEnkY85i8+40bhavZ4OZkuJPjFoD6qOphbP/i1Cao8y1aT8vBZp5o18K7HfdoQALp2Rr e8khHioCLbTEx9jSIXCb8ke9ZVMtFlWREX4RDqR4jC/fx8/c2nnzVaV48QEtV8jOhe6l do5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kw5DmJYSpDmuJznmwAMRHQCtGgWe5nKFfzGdrXYI1X4=; b=re4RtGK5UMDgdaJU7fb8Va+SF86YsRdc608fAhuhxbEplpo+LvgZef4Od/Pd6iwI+g IF1Nx+VSMQk2maTNiT+Ydk8e8PN4OKtBXBTw1rUm8lR2b9JA5hQCt3P8gw8c+zkU/afO fOVb1bUvRgslvoxczkE6FEvJTdWyp99j06IDYbYiaseA/J7E6CUWcRUxgwbWbGd2I4he qFtWOr880zeKhjfT98e/LhuTb4zHRTdO5qNDi+LxlYSxT4EQCu8pRBqryyx1dnnJ21PB jJPHDqQ+AFMtme+h9Z/TX24/wC8B5KxLadamPsXx5Oo5it6FkP/U2w871yiMQmx5C2eT seqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KtUGzzrt; 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 f28si8567884pff.131.2018.12.01.07.56.32; Sat, 01 Dec 2018 07:56:46 -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=KtUGzzrt; 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 S1727242AbeLBDF7 (ORCPT + 99 others); Sat, 1 Dec 2018 22:05:59 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:33807 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbeLBDF6 (ORCPT ); Sat, 1 Dec 2018 22:05:58 -0500 Received: by mail-lj1-f196.google.com with SMTP id u6-v6so7649671ljd.1 for ; Sat, 01 Dec 2018 07:53:08 -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 :mime-version:content-transfer-encoding; bh=kw5DmJYSpDmuJznmwAMRHQCtGgWe5nKFfzGdrXYI1X4=; b=KtUGzzrtlk2DxLtkU0GSvQOAnNzIWPXRRGKfQe2yVbwdXt7ofrw5D7dZ8ce12OaLCS unXZVIEy3vPQ16kqH5pI9yPTK5v/QOf7A0D/cUQQmPmHNSyWQnpzvMT+Mg6n5OHACWKu Mu+sU2Hzi82ZRIhvlvRDcvy6bW5MtXlNd00RA= 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:mime-version:content-transfer-encoding; bh=kw5DmJYSpDmuJznmwAMRHQCtGgWe5nKFfzGdrXYI1X4=; b=KHvq9rfhICsOYHnL1U75pI36oQ55/oxT07883cNxA7trj9/Am69nZCEfB1xz41YsCa CoxLXei9OOc4KoSBz4SrmNNE6nxDf2QTeVw40WKYtqZtNZ2kkMGYx+7HlAC8qgfMcVPY L7wYGF/wU2YAz/FyG9MLusSKz/t7Zq4tYxdH2Pg0Joqay7mzezF8fVpK+y/GY4NEHbv0 51d+E5ldFknBjwMVNvmHgrmEXpCPw1+L+GOa2L8DHOaytVek4Vzm3T9DPbZyW/MqkbBG PUCJ12XjgrnhASQZkxdHh9b5Qco0H1BRH8vor/KsPoh2xTxplWFYkBLIDOO6Eh7zMBAu klBg== X-Gm-Message-State: AA+aEWYa4CNTMs355+4jd8qrYVgWP/ZEqrFyT+9uYHJvu6zqUlDXuLmc y4OhKAKParS9acerRhnLSha1qw== X-Received: by 2002:a2e:6594:: with SMTP id e20-v6mr6836862ljf.123.1543679587802; Sat, 01 Dec 2018 07:53:07 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:06 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 03/13 v2] regulator: lm363x: Let core handle GPIO descriptor Date: Sat, 1 Dec 2018 16:41:41 +0100 Message-Id: <20181201154151.14890-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod_get() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fixes: b2d751b7f69b ("regulator: lm363x: Pass descriptor instead of GPIO number") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the gpiod_put() on the errorpath after devm_regulator_register() as this will be handled by the regulator core. - Put a comment in the code so maintainers knows not to use managed resources (devm*) --- drivers/regulator/lm363x-regulator.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/lm363x-regulator.c b/drivers/regulator/lm363x-regulator.c index bbedb08d257b..8c0e8419c43f 100644 --- a/drivers/regulator/lm363x-regulator.c +++ b/drivers/regulator/lm363x-regulator.c @@ -224,13 +224,15 @@ static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, /* * Check LCM_EN1/2_GPIO is configured. * Those pins are used for enabling VPOS/VNEG LDOs. + * Do not use devm* here: the regulator core takes over the + * lifecycle management of the GPIO descriptor. */ switch (id) { case LM3632_LDO_POS: - return devm_gpiod_get_index_optional(dev, "enable", 0, + return gpiod_get_index_optional(dev, "enable", 0, GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); case LM3632_LDO_NEG: - return devm_gpiod_get_index_optional(dev, "enable", 1, + return gpiod_get_index_optional(dev, "enable", 1, GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); default: return NULL; @@ -263,6 +265,8 @@ static int lm363x_regulator_probe(struct platform_device *pdev) LM3632_EXT_EN_MASK, LM3632_EXT_EN_MASK); if (ret) { + if (gpiod) + gpiod_put(gpiod); dev_err(dev, "External pin err: %d\n", ret); return ret; } -- 2.19.1