From patchwork Wed Dec 5 12:47:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152891 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255671ljp; Wed, 5 Dec 2018 04:47:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/U4gYK+j3YhP7/WAIoSizixVLbtpk3OgGinrR54/irQfJmXXddDtGWOqekXnFqQyCZUJULS X-Received: by 2002:a63:374e:: with SMTP id g14mr20747102pgn.59.1544014063085; Wed, 05 Dec 2018 04:47:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014063; cv=none; d=google.com; s=arc-20160816; b=SpXGlF6OJ5VmL4sjeuCuV3A0aV02E0UIN7VkHoT+SJ95WLK8Rqkn52U13VyxLZeMK5 VHSKndRbK0tXW6GBCT9RJDtK2dqk4xUrUYG5N/+7s0iYVgtQKnbcibQmeM3i1LoGZltP bvjGsalGtQ+MoFbiakAkHl3JOhy+FpLF9cTmz4F4Xsi8zEwQqfzcMau5t14QYzGG8qtG MIB0zu4JrcVnBvZ81ZfUqvstzLEhi1h1gggWGo9Uh8Tp5JqX55Apb4EddBXtiqxrxUrU YPM3axdI591hnXRT1kXm4Q1eD6TJGn697gw89OJXdK47H01vPxLMGaRrsPVYVfxdWqp5 ik0g== 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=yYp3S/IRQJmcBgWx8RZhYl171BsROIDwACkCZb3Iuv8=; b=hStDl5QD1QLAyRGIUiYylQGi1KistuUzd2YIuf2nr0ZxH3cnl4Bya2utUadut8sQ+f 7ms3jTa+nogObanlSbuzbZJpuua1B0Q2cA0JXZEZ4uzoE+Am+u8F84v47IA6vNY77TH8 NI+11ne81MqJxaRH51lsPtsM43NWKUdUqtbE8GI+5BtPUHM46zNVUpKfVwL/jKIEzkSt DgnJuxO2pQIMa1YWj85MHFBEptxR4KaIiGmuy+ds/9fqDmVL9LrRfS/dMiGSZ6hvd/lF dtFVoA9gqfd9iEHJ+H8T5qwKVXWNDQJi2YdxrcmvwYAZFtk4KB1kPZWKGEuh75t21Zjq qFlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ma63Pt9B; 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 m19si18583185pls.437.2018.12.05.04.47.42; Wed, 05 Dec 2018 04:47:43 -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=Ma63Pt9B; 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 S1726149AbeLEMrk (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:40 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46134 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbeLEMrh (ORCPT ); Wed, 5 Dec 2018 07:47:37 -0500 Received: by mail-lj1-f195.google.com with SMTP id v15-v6so18174964ljh.13 for ; Wed, 05 Dec 2018 04:47:36 -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=yYp3S/IRQJmcBgWx8RZhYl171BsROIDwACkCZb3Iuv8=; b=Ma63Pt9BEM9ip4CwNsk4DDecTc7sh8LyWBa5bjzjs/mLmRXXUlgqSkEp97IEyzAot5 XZyC0cwZol6hziuA6SHd3eElxXMpxsmT7qrt9YedFlkuFLx04PXkR/N79jCbDrnwF/wJ uCybcGNUAI4X7Asurbz/OLrTaIFKHkiHhFxLo= 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=yYp3S/IRQJmcBgWx8RZhYl171BsROIDwACkCZb3Iuv8=; b=M+7Bn+vVKrHqjGTRsHqWkk2l2BvmgnJCeNQ2PK1DWvf1EwAJl9k198a0Mvul52ZB6j EAqOhzjlagt0HVepkL6jKpsoOyxSney+NfB/jJ+QB9ax4YXytJV7pWXPJCAD3Y+7pgH3 2ydDSHOh+ZNVpj/F9RsxtsqBsARQderdUDfkDB78Namx6nKXXoChYtivCA6ayRwC0wCz k+Okf9FFQuGi+5Sx4KqpHXKyGWLk2LyX6ikz6+oZX9t/6zvzzZdCNFUWSy7bc9WRuBu2 dLyyRHjfHYKvPaq6SReAInl55+GpI8NyxQLWLUK9Kz6eTRaQAop3h8BxqL69HRDEP7rm iVbA== X-Gm-Message-State: AA+aEWbTx9YSh3eZj8ayD5EhPWVFKQS4m5U0UqG6aTV1S3FwYtXXPGyM WzgYwE8mAXy8pdQkKUaOMU44Kg== X-Received: by 2002:a2e:5109:: with SMTP id f9-v6mr4227555ljb.52.1544014055704; Wed, 05 Dec 2018 04:47:35 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:34 -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/15 v3] regulator: lm363x: Let core handle GPIO descriptor Date: Wed, 5 Dec 2018 13:47:09 +0100 Message-Id: <20181205124721.26624-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. 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.2 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; }