Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1831846imm; Mon, 3 Sep 2018 10:34:07 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbuLpZTfCq/KIgs5fJvbPIRLF2mDdzyq+Eoyb9M4OuzQ5XIfE59qLH0KLIwiM7VAMAJsr98 X-Received: by 2002:a17:902:b03:: with SMTP id 3-v6mr9435272plq.156.1535996047467; Mon, 03 Sep 2018 10:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535996047; cv=none; d=google.com; s=arc-20160816; b=eOAkMFHlLSYCs2R0CrTZfkxbuJlda7lrV9tQtjlHUFeAiD9k3n8+rOFTALzYem+f8O f3mq3M1JFbbugybb4n9CMACheYuN3ZtUO8QZ5z/2v9JtwSCW+5Adh2mpZE+7itSCKQUj 9Wli3PoxOrGdwqMOnW8q5tOKKN3lgk2hVsxH8TlJV5nMU4xBq5edoPkTE1bBOuCo0M0x SopZG0JrNPiQtsN8sru4LH/dfPAgb1XGWZeOOZr5pa0EP38bZE5hEBXtq7x7IXqNOzNt NIzYQ1sf/HHPSsZBRGEPMUZXRC/grNHmYXeZ0aPo+XOQBKmusRobXq0S/HG9QoxOLBrB 8VBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=un5sbFpWVK3IcaphGQJQMPB2UbTRn9//0qEsFbuCKz0=; b=m7Pi/4vq4maq0jp6HOnfN8tRI+Qiu2pBaRX3FAaWrwy6k4pPLZdv8OIq52CN87i+Ol 4i2ylyLs4RRn61lyDof+qITVnrvEYfxWCjm4ZKy/Mxgetn6B0ffg+gQ/7UPCp7nIda55 tHatqvz3E5033drhlYefBo7HMfSDwSKkxtV7eLQCaC+Y8uootnvJiw46qXXnDgQgnFZM V6iVAi1VWfM3hraVJRH1LpI8Bt6PSOyxctJ1+pFigovXpCV/OGi6lsOgOloxjAU2f8mf RKA9Oniu9b7yZj3L6ycBSvxAZ0gjBPoHFnqnT2JAaKO+kvF4ZABONo66nv+c967aXaQF wyBA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5-v6si18283934pfg.258.2018.09.03.10.33.52; Mon, 03 Sep 2018 10:34:07 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731221AbeICVxf (ORCPT + 99 others); Mon, 3 Sep 2018 17:53:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47508 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730697AbeICVxe (ORCPT ); Mon, 3 Sep 2018 17:53:34 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5A9DFD1B; Mon, 3 Sep 2018 17:32:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthias Reichl , Charles Keepax , Mark Brown Subject: [PATCH 4.18 023/123] regulator: arizona-ldo1: Use correct device to get enable GPIO Date: Mon, 3 Sep 2018 18:56:07 +0200 Message-Id: <20180903165720.479439043@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165719.499675257@linuxfoundation.org> References: <20180903165719.499675257@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Charles Keepax commit a9191579ba1086d91842199263e6fe6bb5eec1ba upstream. Currently the enable GPIO is being looked up on the regulator device itself but that does not have its own DT node, this causes the lookup to fail and the regulator not to get its GPIO. The DT node is shared across the whole MFD and as such the lookup needs to happen on that parent device. Moving the lookup to the parent device also means devres can no longer be used as the life time would attach to the wrong device. Additionally, the enable GPIO is active high so we should be passing GPIOD_OUT_LOW to ensure the regulator starts in its off state allowing the driver to enable it when it is ready. Fixes: e1739e86f0cb ("regulator: arizona-ldo1: Look up a descriptor and pass to the core") Reported-by: Matthias Reichl Signed-off-by: Charles Keepax Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman From: Matthias Reichl --- drivers/regulator/arizona-ldo1.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c @@ -36,6 +36,8 @@ struct arizona_ldo1 { struct regulator_consumer_supply supply; struct regulator_init_data init_data; + + struct gpio_desc *ena_gpiod; }; static int arizona_ldo1_hc_list_voltage(struct regulator_dev *rdev, @@ -253,12 +255,17 @@ static int arizona_ldo1_common_init(stru } } - /* We assume that high output = regulator off */ - config.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "wlf,ldoena", - GPIOD_OUT_HIGH); + /* We assume that high output = regulator off + * Don't use devm, since we need to get against the parent device + * so clean up would happen at the wrong time + */ + config.ena_gpiod = gpiod_get_optional(parent_dev, "wlf,ldoena", + GPIOD_OUT_LOW); if (IS_ERR(config.ena_gpiod)) return PTR_ERR(config.ena_gpiod); + ldo1->ena_gpiod = config.ena_gpiod; + if (pdata->init_data) config.init_data = pdata->init_data; else @@ -276,6 +283,9 @@ static int arizona_ldo1_common_init(stru of_node_put(config.of_node); if (IS_ERR(ldo1->regulator)) { + if (config.ena_gpiod) + gpiod_put(config.ena_gpiod); + ret = PTR_ERR(ldo1->regulator); dev_err(&pdev->dev, "Failed to register LDO1 supply: %d\n", ret); @@ -334,8 +344,19 @@ static int arizona_ldo1_probe(struct pla return ret; } +static int arizona_ldo1_remove(struct platform_device *pdev) +{ + struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev); + + if (ldo1->ena_gpiod) + gpiod_put(ldo1->ena_gpiod); + + return 0; +} + static struct platform_driver arizona_ldo1_driver = { .probe = arizona_ldo1_probe, + .remove = arizona_ldo1_remove, .driver = { .name = "arizona-ldo1", },