Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5117507imm; Tue, 19 Jun 2018 05:26:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLOlJUXhrDQQYq0xkYUpzX1qZ5SKFQjCoKCA6gKhDQCcb2CmZzTL7AiRPGM0qEhHb3loiU4 X-Received: by 2002:a62:9bc9:: with SMTP id e70-v6mr17725036pfk.15.1529411208252; Tue, 19 Jun 2018 05:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529411208; cv=none; d=google.com; s=arc-20160816; b=EW4UyrBL2pGwy3uFoDdclmeg0VfjqLm09+mIu7qmcrwtVrZ7XgZsJk+VLOXvS5qCbh GdpX6BZ6cQzkAgIacFcLsN+l1ZM6XbX7a9Y9AwKItCCTaYJmoyCsrFIS3wttkvepWqex K136V8eF3nIasZYFEshyBeH7dL/YiDZktBiUy7A2GGm1drVwh2nHOmAnMLS4ZEVWJJtb 4gHxzFo3ZPGAvQNEsZb7xzbcy0yJyUd8N0DkdSNKa4E1Jku/z4cclfeEz/jEKxEiKqiE rOvIW8iTmImTRHrXu2ddGdcoVpRPZnnXqyBdYOwyjjeJYCQ3cFMIh5tklG4eV2egkNiQ 8FcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=QmkftLUPeTw5xKNUnktNp05QlXSVTaPMINkqTa7OB3M=; b=vdQjy41lth2JHd3dnwGA8CAUR61G1a5NbCj4911gL+5///7ZqwH7wdd0gm8spnO0A2 G1FwAAFilbZiWv+Mc+eDu7BFn4WiKq/cwM1M5Z0KFjIYLGezRbysRi5vhe2UteCcSU53 Eq7SS4QBb8MZINgX5OUzqFj2IM+UmAk6W5kxzNh2Xnu3Oht3gNx1M5V0Q6N4ah++ckYJ utnaPadqcSbsJKJ6Hzq/LJ648Pwmvz4xogM3hoZlUasQzRigQtrdWXWg1y2KJ4W0UVP5 trr6BObbIS4V63u68TZJ/odBBtMJPjUWuM38mAL6cDXejFktYQ3WdXZKNShqqToTOUIJ PMPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@horus.com header.s=20180324 header.b="ZEJ/P/U5"; 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=horus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9-v6si19443908pli.382.2018.06.19.05.26.33; Tue, 19 Jun 2018 05:26:48 -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; dkim=pass header.i=@horus.com header.s=20180324 header.b="ZEJ/P/U5"; 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=horus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937796AbeFSMYh (ORCPT + 99 others); Tue, 19 Jun 2018 08:24:37 -0400 Received: from mail.horus.com ([78.46.148.228]:48988 "EHLO mail.horus.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937502AbeFSMYf (ORCPT ); Tue, 19 Jun 2018 08:24:35 -0400 Received: from [192.168.1.20] (193-83-224-126.adsl.highway.telekom.at [193.83.224.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "E-Mail Matthias Reichl", Issuer "HiassofT CA 2014" (verified OK)) by mail.horus.com (Postfix) with ESMTPSA id DB9896409A; Tue, 19 Jun 2018 14:24:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=horus.com; s=20180324; t=1529411074; bh=QmkftLUPeTw5xKNUnktNp05QlXSVTaPMINkqTa7OB3M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZEJ/P/U5oxu7NqYOlDADxcBl1C6pdE9T3PHCCIXTP4PECoix3thqAwlNV/KKXoucH bXZ8yWhr+rGc9+0QBooABTcZv1yZJmnRcK798gPYDVEBNboO/TTLOu4M76zD4xxozU //DbDlwIL01WHmlO5ex02uBzcUFTZEML8vcGBfCA= Received: by camel2.lan (Postfix, from userid 1000) id 3EEFE1C7228; Tue, 19 Jun 2018 14:24:33 +0200 (CEST) Date: Tue, 19 Jun 2018 14:24:33 +0200 From: Matthias Reichl To: Charles Keepax Cc: broonie@kernel.org, lgirdwood@gmail.com, linus.walleij@linaro.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] regulator: arizona-ldo1: Use correct device to get enable GPIO Message-ID: <20180619122432.6rgh4zjqrfk45ofs@camel2.lan> Mail-Followup-To: Matthias Reichl , Charles Keepax , broonie@kernel.org, lgirdwood@gmail.com, linus.walleij@linaro.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org References: <20180619093245.1261-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180619093245.1261-1-ckeepax@opensource.cirrus.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 19, 2018 at 10:32:45AM +0100, Charles Keepax wrote: > 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. > > Fixes: e1739e86f0cb ("regulator: arizona-ldo1: Look up a descriptor and pass to the core") > Reported-by: Matthias Reichl > Signed-off-by: Charles Keepax Tested-by: Matthias Reichl > Apologies for missing this again, we should have caught > this in our testing and thanks for reporting it. No problem, and thank you a lot for the quick fix! During testing I noticed another minor change introduced by commit e1739e86f0cb, see comment inline below. > > Thanks, > Charles > > drivers/regulator/arizona-ldo1.c | 27 ++++++++++++++++++++++++--- > 1 file changed, 24 insertions(+), 3 deletions(-) > > diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c > index f6d6a4ad9e8a..a981896c056a 100644 > --- 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(struct platform_device *pdev, > } > } > > - /* 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_HIGH); The WM5102 datasheet lists LDOENA as an active-high input, so GPIOD_OUT_HIGH causes arizona-ldo1 to start up enabled. Not sure about the other devices from the Arizona family. I did some tests monitoring ldoena and reset gpios with my scope: With commit e1739e86f0cb reverted ldoena changes from low to high about 1.6ms before reset changes from low to high. With your patch ldoena goes high about 11.5ms before reset goes high. With your patch and GPIOD_OUT_HIGH changed to GPIOD_OUT_LOW the delay is again about 1.6ms. So I guess it'd be better to adjust the comment and change to gpiod flag to GPIOD_OUT_LOW. so long, Hias > 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(struct platform_device *pdev, > 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 platform_device *pdev) > 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", > }, > -- > 2.11.0 >