From patchwork Sat Dec 1 15:41:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152639 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934563ljp; Sat, 1 Dec 2018 07:53:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wxq4/OJYrKB3wsqXiHqax9wtTL6ZJzZolGq1TWN1aC092AIq+C51wMXBcfPYqCyaybH3eD X-Received: by 2002:a63:2c0e:: with SMTP id s14mr8323897pgs.132.1543679603614; Sat, 01 Dec 2018 07:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679603; cv=none; d=google.com; s=arc-20160816; b=ZjBtTbrhlNeHah8j0waPPUFMeVvp1Rb0SVDoLbhBGLhIEhC9x733aGOw9bwtczWM3F TP1861DIxRyIq9NFLZcR+AgjV+Cb5GiXj5QGqZlQyz8ud29BQHDAfHCSZVicq7VUej6J oCpYGVLNswETqNe/sDKf2/COzCuQeGXsts3ImIMblELcaJ7CLFEkX0aNkkQs1uAxgQoZ JzznotEbhLHdaJOJTQZsPqApf2VIbFESe05hhEhzLZTfyj0TSMUN17wYxHoWGCzqcsam PBKGeqZoxqbQL+AI+QPT3xQq/0AUng13HF2zNHQeMI848krwQWKeVmTEAHa272nPrwjn WDdA== 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=WoT+Ndj5Ei0kF2uLiPdGvTf6lS/9r/F3o57+S1DbskE=; b=NtvAVZJU8Xfykglavp7I6vVEOyRsG+pDEXblt956btx0nD8+sqWm0kZ77VtaoENL+i 6wLmXVA1fejOJKMVraZWijHWy/TIOSKYAlPZiQ6JmsiHv8W7vKzUDNI5HgQXusv9DtPr YWVqoKQkHc4K16/1Kzxd0pAhR3I+L8MiB14WCP57pEMiW5Mq+UlJQRa/AzLgWm4KSXiG /X1cD8wetqIxnc7SOm+N9jS7e1R7HEnb+th2AoPa91yRjnsBX/HCseTniuqunuQNf1GX vH/XHn/tBThVRxFpOCdiBNInOWvbqmsA6PSV87+w5/zm8/z+ZkHEiLoMzNsqEGLiqvjh E54A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XgnOSiwj; 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 e8si8366903pfc.248.2018.12.01.07.53.23; Sat, 01 Dec 2018 07:53:23 -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=XgnOSiwj; 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 S1727342AbeLBDGJ (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:09 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35363 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727293AbeLBDGI (ORCPT ); Sat, 1 Dec 2018 22:06:08 -0500 Received: by mail-lf1-f66.google.com with SMTP id e26so6229085lfc.2 for ; Sat, 01 Dec 2018 07:53:19 -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=WoT+Ndj5Ei0kF2uLiPdGvTf6lS/9r/F3o57+S1DbskE=; b=XgnOSiwjI4z9wgN+Zk3ZjjQlIhLlyC1NH653lGFo2zo2zTOJb1CuYW47Ex7XY1Ab/V r2cRc8S2nTecGtBUiwgmZJxpbH3QMYlTJhiFswmzR/RmtExPjcLKF+15fd0JI5xJKUx5 Dh6P3LP1mM7tBP85vFusmxS+LR60x+ZNJ0tm4= 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=WoT+Ndj5Ei0kF2uLiPdGvTf6lS/9r/F3o57+S1DbskE=; b=VKomQvHMmOb3Vigv1y4GFPNVl4PQ2DOv2t/bo64P7ipYNgRVolqCRdAipvrwolHuDW yClsru2f9M1EXeQNiUjeXV41WOJpjSxb6uKEDeUlKqfoa1XPaAIfdTjuXRDyHMPLCt5l sH2wvTvx2zMMGzjnuBCI6vvqzc7mOmnP4nE6fyotHRaMIfDv397cJC2Y6z8bC8w2MlUj Jqsu51ee8TOlmOPCCs+LI/bBQAlSjAF53+Lgha3GH25h9VWkuxSWIiyR0cGbgBWTdWe9 F4rOBgS5RGHtAHNYaX3uuCZoHoyK9+1SV+5Rbbn7Euqrv59siRLNwji0Vj1nTCxiqQCh YVeg== X-Gm-Message-State: AA+aEWabScmJnpHIyxYI/vsmWC2lKpmlvTH0+MbfQD1MINXsQ5+UTIsv A0dVkXxgf3NZ4bZFUs+gdKLPpg== X-Received: by 2002:ac2:4116:: with SMTP id b22mr6073306lfi.19.1543679598621; Sat, 01 Dec 2018 07:53:18 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:17 -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 08/13 v2] regulator: max77686: Let core handle GPIO descriptor Date: Sat, 1 Dec 2018 16:41:46 +0100 Message-Id: <20181201154151.14890-9-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_from_of_node() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fix up the errorpath so that we free this descriptor if an error occurs in the callback. Rely on the regulator core to deal with it after this point: a previous patch fixed up the regulator core to properly dispose any GPIO descriptors once you call regulator_register(). Fixes: 96392c3d8ca4 ("regulator: max77686: Pass descriptor instead of GPIO number") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Handle the errorpath (hopefully) correct, back out of regulator registration by freeing the descriptors of all not yet registered regulators. --- drivers/regulator/max77686-regulator.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) -- 2.19.1 diff --git a/drivers/regulator/max77686-regulator.c b/drivers/regulator/max77686-regulator.c index f5cee1775905..8020eb57374a 100644 --- a/drivers/regulator/max77686-regulator.c +++ b/drivers/regulator/max77686-regulator.c @@ -250,13 +250,13 @@ static int max77686_of_parse_cb(struct device_node *np, struct regulator_config *config) { struct max77686_data *max77686 = config->driver_data; + int ret; switch (desc->id) { case MAX77686_BUCK8: case MAX77686_BUCK9: case MAX77686_LDO20 ... MAX77686_LDO22: - config->ena_gpiod = devm_gpiod_get_from_of_node(max77686->dev, - np, + config->ena_gpiod = gpiod_get_from_of_node(np, "maxim,ena", 0, GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, @@ -271,9 +271,13 @@ static int max77686_of_parse_cb(struct device_node *np, if (config->ena_gpiod) { set_bit(desc->id, max77686->gpio_enabled); - return regmap_update_bits(config->regmap, desc->enable_reg, - desc->enable_mask, - MAX77686_GPIO_CONTROL); + ret = regmap_update_bits(config->regmap, desc->enable_reg, + desc->enable_mask, + MAX77686_GPIO_CONTROL); + if (ret) { + gpiod_put(config->ena_gpiod); + config->ena_gpiod = NULL; + } } return 0;