From patchwork Thu Dec 6 12:43:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153013 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479179ljp; Thu, 6 Dec 2018 04:44:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xx2373gI8U3eXDYnNO6d0XAK/b3FfI1zjOq/kywRcNQpV9ihTtQl5aZDHZqskHyDFCP/qB X-Received: by 2002:a17:902:a9c4:: with SMTP id b4mr28148751plr.298.1544100252865; Thu, 06 Dec 2018 04:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100252; cv=none; d=google.com; s=arc-20160816; b=WXHWtzv7L5HLLTdgXatvEIz6XwyYGFNoWYrwcIK9Yx3Se5DaYV3DSxK5hC5nkqXI6c ieunKX6jFOwPTBiFkFnet9+CJGy9GLcU38SEUJhClAKKAKaDowYHsqhO5ccFFfz8sJ7P VJIL5wZ/0JTidAzyTUPTVNyeFkBRQNrGjvEski9dqq/tCUUsDkm4fWan2ho7Pi2TB2J7 gE+YkVq6zuVkD3gytOfKdElSpBC4mDycxSLsO9BYQKhgqMz8DdgJRQ2UQhvRQeBl2acR ju5+ANqNJvFJ2ZwvZ7qArOtLfh7/auWinCZauHkz7e4yso+vUk6fqrFyPFJH6dC0L0L4 91nA== 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=lJvN9Rzv+0xPXleQeFq/pULseUhFiIrJUg0MsYbkIQQ=; b=RsaNNN6hVys6MkLEc8/uUuydV9So7f9/6jXzqTOGBGt6IM3aT9CIQ0RCMwuZUipQT7 eg0IutfzYtS/98QWFqSiLvHpwgVQBhakA0pHgn+fZ4soBNCYZxsmN9H7ZdegcPlQv2MG FQXS4lY9+3vQgQHbl4ZWC9GMKmBTFiKoLujclLZ90xeLpuAN5/g99pPJheIQ4JrK7M1O Wn4DKQawVOn5WU3x0j00yO/ediF8LAEIyoo/Zf5ECjihLjoNOYcP4bMPAdXD1w+o7X3f RXH0NMRLRAN742xGy//4kBMu/zh5KKqOgUy+an9TsoDOrrWQWjRS9mymukX4SO0UNmDi XNlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jErdw6p7; 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 p17si201618pfk.275.2018.12.06.04.44.12; Thu, 06 Dec 2018 04:44:12 -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=jErdw6p7; 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 S1729651AbeLFMoL (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:11 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35133 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbeLFMoI (ORCPT ); Thu, 6 Dec 2018 07:44:08 -0500 Received: by mail-lj1-f195.google.com with SMTP id x85-v6so305847ljb.2 for ; Thu, 06 Dec 2018 04:44:07 -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=lJvN9Rzv+0xPXleQeFq/pULseUhFiIrJUg0MsYbkIQQ=; b=jErdw6p7lQSVYfE6FJqDsTaFKkD2INS1kz7U5/VH+Oe1DtxgVxoQejsEyhJn8aa/Uj rnhKSwjdozbLDI7C96cU2XyAuQJmIVq0+NbZVqX1KV41SRUxoreovVGDZZlFSeJ1IZ+I 3ycGk3aT/73Q+ed3Lv17SxV0u4yq/4lRq4T9c= 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=lJvN9Rzv+0xPXleQeFq/pULseUhFiIrJUg0MsYbkIQQ=; b=AmSD562DStkg2B8W4/bIPe6Zs0IaByyGkwfG/+pK6Y8ujTymwKnMH4nZ7mdInRJMGq iba1ExPM3IYpWsG1uk1uJz87R6srp35hpypr6tYXdQJ3nwxHGbQG5pjnHSElHH64uIf7 Nwq44jylqnQMGZXus1WeHHxM7I52rdzKDpe7jpTERCrOHWuM4LsiNDjaadUs97khT8nB m2GD11jssrhOTWSlKk+OQCcjvQzSFi/blwj+CfzDddONbAYJzzGraamBwLmRnKszG3Zb Ydmjo+T1pTaL6Sag1AvgzC2KwMCFWGKNSYeieQJb4EMMdyazxHRNLN5gR7PdqFNMEndb 2g6Q== X-Gm-Message-State: AA+aEWbaGstLTRRc5IwHP91EOMhjp689u7wD0GEg3K8mS/b54jC0UPFO mcmHNmUp/oVtl6bzZgtVSOhVHg== X-Received: by 2002:a2e:9e95:: with SMTP id f21-v6mr18222992ljk.128.1544100246324; Thu, 06 Dec 2018 04:44:06 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:04 -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 v4] regulator: lm363x: Let core handle GPIO descriptor Date: Thu, 6 Dec 2018 13:43:39 +0100 Message-Id: <20181206124351.10155-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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; }