From patchwork Sat Dec 1 15:41:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152634 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934437ljp; Sat, 1 Dec 2018 07:53:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/V1HElcUSk3ZmE2IK8hDft8o3MVqAlYO94BKeSwY7N6D8bhlVQZGjpXu5w9wZpOQiw08UI3 X-Received: by 2002:a63:a611:: with SMTP id t17mr8079832pge.338.1543679593800; Sat, 01 Dec 2018 07:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679593; cv=none; d=google.com; s=arc-20160816; b=apoj5/AuvuiKZBnlMHtBroqM5aLk8WGnKi+6Ex8RXZ4mN0H4xBLjg3Vtv7DQPj8Q6b GcXcJzsu2r/BCxvvV2drg4KbxSjSpryr0UhyOG1c5zyl/hzwojY1KHdM0/vmPIprDPu7 VNHvhxxuWaoKs9yGAf+l0rKY3oKg+gDkoC+LtQX9rEsrYbWnh/PETG1fbgm0tYn9NlIg Kv4agNb2BDn8X2cSABHq7qIca1tHqnTPHK39sWllcZHIAAaRqFc30vQ9XFqRH5FVxQEW 7GSnV8LaMAwoJxIaObeA2vhVv4kNIcRGE2M6k8JP2DTZlnLLIgEMOxZUtb1HWQDXz/FW 8ySg== 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 j3si8249538plk.199.2018.12.01.07.53.13; Sat, 01 Dec 2018 07:53:13 -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 S1727248AbeLBDF7 (ORCPT + 32 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 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(-) -- 2.19.1 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; }