From patchwork Wed Dec 5 12:47:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152894 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255810ljp; Wed, 5 Dec 2018 04:47:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/UtT7oTY4DYBarxizamRdZb7c+r0F8WCLfY6S0Or3I9KYIMsK4x8ngB2Z3kad5CB4Z3A1wN X-Received: by 2002:a63:e5c:: with SMTP id 28mr7756323pgo.369.1544014073111; Wed, 05 Dec 2018 04:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014073; cv=none; d=google.com; s=arc-20160816; b=v1YTbrvL5DlGYJdQyKPjx/2HC5FpSYNTjQmAa2KgLf79RxQvf2dQVu/eh2/4U5mESh Ov+2DPp6Amh2zeUOQ0dYdLG/VyY+yBtbv7PntCXCJ3eDOtrZLNJXUbbfMeqL4Xs1/9HR IY19RK1fUfVfmnkDWdf4NFNamHDUbpraM1fmOrCz1dNzSpb53DclLEy115TU6R/sX00o o6YZMir6q/4nXgk+MtBQ8TtlWDDzlwCL3ZiIK51tghjleEWOt0xJEnu3Hwhsfy8VA/8m cnxlQd+5gHgbiphyJmYG8DBfWBcRC1pBE61A2IpYbpze48F07zkuRfwUdi9y9k+PUcI0 noyw== 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=qTwEgaJuHML2/WugrEbTAW9s/jIgwlSTFOzt/GYbDJk=; b=y4XXbw/JRQHZh75sqsxcJWpiB85mo7EftY1ZZEfRRT8N3sQLv+3DL13NLoDljYtsRI ImGhbQPwmUfj1gVnIu9LZ2onNwR32JeRUAo0oX/8FedriIX6APk//Ch/SFElVu801Q/N oYjQOLZiyG9f/OZotnDsn32HlxE4+hJLzMlsGFJ07MKGTaPbHt4AtO09zdj9qBcUilFL HnL2qTgiSR+M1quxkHGyq9Y3gspiHCpwRuEW3iP099uRPejN4xlqtQpAQHSBcA/YfKy3 hI3JowiSZYnp7aC9s9dqZHWJOTi42H82/RxWfQCYoePb+Yy1v2jZisWviejRY/p9FcqT Q+lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ScvXDerd; 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 184si18679578pgj.329.2018.12.05.04.47.52; Wed, 05 Dec 2018 04:47:53 -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=ScvXDerd; 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 S1727921AbeLEMrv (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:51 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35150 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727898AbeLEMrs (ORCPT ); Wed, 5 Dec 2018 07:47:48 -0500 Received: by mail-lj1-f195.google.com with SMTP id x85-v6so18213586ljb.2 for ; Wed, 05 Dec 2018 04:47:47 -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=qTwEgaJuHML2/WugrEbTAW9s/jIgwlSTFOzt/GYbDJk=; b=ScvXDerd9AjqpSTtybMjmLDBmrN/dJTK4LZtUTVLDI8K/hsBSik/8My7fIAhAB0JpM CY2z6RfbQsonquJTdfMp7uO+zPewcW1EaZrYBjm4XvcdIkurSp1KKLQrZ9iAcQmP6KJi H7xa3mbRBhl1eCYurlEPEGzjRcBl00fKqTI4Y= 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=qTwEgaJuHML2/WugrEbTAW9s/jIgwlSTFOzt/GYbDJk=; b=BGBhNdJ82CbohbNfizrYni/Tcn0qPdpDOoiz2B5+7wItiWRTMK+jWgPeW2VM4PK5mf y0MiS+9Qkkq0dn+BL0Di9R518W+8Zj6iMVNdnkCqg9Bg72Aqxglx+16F5TpqCcurhD3A 5yYzWORyhbxOFsxeua5IZGVXt0gfuVOLqXSDwHYDliFMWUllI44bCLYVEzyaXfY0sDjC NiIUZmHGctk4O1CGITQjxQbFY+fP7EiznJWvd/31dfmjZ4NIDbsFufNj7S6dJoKYGerv JtusmuaXV5eU9nbRoVW7TF8qzmyynp/LUDjMIfZeqhDKwQbTKerh/9jU9DA9NMVW1ht4 mpLw== X-Gm-Message-State: AA+aEWbXVFqZsAsUoPbwmiR74QpFKOCJxl6UxabWP6BVtEyWhF6Qrc0L mCQ8aWTERxO43NsO8U4apTciJg== X-Received: by 2002:a2e:9dcb:: with SMTP id x11-v6mr17299442ljj.158.1544014066335; Wed, 05 Dec 2018 04:47:46 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:45 -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/15 v3] regulator: max77686: Let core handle GPIO descriptor Date: Wed, 5 Dec 2018 13:47:14 +0100 Message-Id: <20181205124721.26624-9-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_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 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;