From patchwork Thu Dec 6 12:43:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153016 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479302ljp; Thu, 6 Dec 2018 04:44:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/X+pkTc/iHLe1amb+NjXdHElghnRW7u2YATnG8fANywx2WLFZ6ZLXVyyoAodfynJriMzXpT X-Received: by 2002:a63:f30d:: with SMTP id l13mr24197405pgh.399.1544100261700; Thu, 06 Dec 2018 04:44:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100261; cv=none; d=google.com; s=arc-20160816; b=aLrg+sdK/DlUMbuKc5IKfSuXR8bL9FSwTOmEIsPovIANLISqbQazP0hBXNILd7F/Ev CR1U7mhr+6gWQetrLymPmspKTERp4l4vGAYCIDHVXZznbDNyMWCw088mJCgsZNxBHJZK 4o2UvmEJwo9eSQgSNCWDG9KWtnqreZQWhaGggyvixgEMU2xkjPP/L07H9rSgrnmW3DTQ pxj/IeA3ZrEOY+j8PJfLTUXYXSfkTgP+SkwJ4XzpNycbPcJ1UEVZ5ZnV1/qGRihehdGJ gHwzpZkLwups+U5NXYrKvXvxwOFK45D/TyVq4dvNobpPXqRdaN9JarFufj5hqqXsUzm1 ZFCg== 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=EGdG41X/n1r/5ZJbvZ7uuuwkxYAx3vmZpL8IIUge2Cg=; b=OXvuuVQuf6N8WCz3I4brtFRC1RrsbaXlbfXE5lw3yhlToQDJTW8IRvCo/rOOl9Pkwv HLPZmL9gLskwFwFF16CI/i4NXN5Ex6Sg1+sKpyMXCzGdoHaA3Gvfu04VExK5vJqgc/Lb s/ST720DVsaMKnno3AcRyK00vrzPzThvGqJwekpANG4+YTzZTp3x9c24/39C5yMTm45a Zu6RVuBB/hHCxqeTU4Ruq3cG9Ch8C/aVMttKRWYoL0aL+S6eWtvifHpUeIXFS3v3pXyt ex1EOfOwQXjxaKVrvjrml87EBxoimepoTaOF9Db3Q/GH+NWuNYcJvejvZDGmfwWCzSmI 10jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cEoEamDO; 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 f10si190892pgl.528.2018.12.06.04.44.21; Thu, 06 Dec 2018 04:44:21 -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=cEoEamDO; 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 S1729713AbeLFMoU (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:20 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:34490 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729667AbeLFMoQ (ORCPT ); Thu, 6 Dec 2018 07:44:16 -0500 Received: by mail-lf1-f67.google.com with SMTP id p6so262513lfc.1 for ; Thu, 06 Dec 2018 04:44:15 -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=EGdG41X/n1r/5ZJbvZ7uuuwkxYAx3vmZpL8IIUge2Cg=; b=cEoEamDOJyLyhIXSAcJMkITLJvl5A4GFRyZHi/JsUzQla3+KgMqYSyqfzX0hrBgqca cV+C1eb9qjhERcqSeXkyU6Fau6T3+SOAT2j4qOKDlpdI6VjdjeKYqeh4N8BSgAORz7hu IGDMdfNWDNt+A+0O/vWMWTYZE20pRK8s4fNtg= 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=EGdG41X/n1r/5ZJbvZ7uuuwkxYAx3vmZpL8IIUge2Cg=; b=Gx4c8QEEbUW9ev4uQ9ZnMZxvH8GbFsi1H+8lgvOSqmEPz/p2v0CdYLCwKKGOT6U7B1 fcsugL/i6opX+LhOm6e02CPLWX3zE4azHHEfTOzcs4vIZK+3P4K+xNHVbYETZL1IbJja mR6dMzFkiddk32lTpSn8wCimzuoYEH5KpXXgKl+rF1cs0Iv/bG/Q+YLQw8n6S0Bz3M2z 8X93pvTIngnBs4H64vZuf4zMlV5joJJlk1phYKZk8HyvTMSNcwsjWCVXY/r+iPhF9cbL fCEIqiqWAEdupX9rpp7N/8YcjuDxMsJ9FNlnj7kNJPSzxzIVt3tijsN5wpk4pOWUF0Iv QjIQ== X-Gm-Message-State: AA+aEWbOwEfwkutZCjSXPH1MSj744wUeU/JsJKd5Ahry/6F/hCupaVYQ /ud6WkVJ3e9Wr4P0s9DRYMd7Qw== X-Received: by 2002:a19:4345:: with SMTP id m5mr16370319lfj.142.1544100254402; Thu, 06 Dec 2018 04:44:14 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:13 -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 07/15 v4] regulator: max77686: Let core handle GPIO descriptor Date: Thu, 6 Dec 2018 13:43:43 +0100 Message-Id: <20181206124351.10155-8-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_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 v3->v4: - Resending. ChangeLog v2->v3: - Resending. 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.2 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;