Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp930558imu; Tue, 20 Nov 2018 09:03:42 -0800 (PST) X-Google-Smtp-Source: AJdET5ctnt32F5FsOwzy+chzY/7lrnY496VGM1yfZKzTynsOgRfuqbKBiFkNUu3aOpPLlzSjaUZU X-Received: by 2002:a62:a117:: with SMTP id b23-v6mr2889761pff.163.1542733422209; Tue, 20 Nov 2018 09:03:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542733422; cv=none; d=google.com; s=arc-20160816; b=x+CrfOyxc0S5MKY7HxBUp1RhECTi3Mv76UUYJUqsgVwIsaYxOOPDVQJyV1sDs634i5 TYw6sZNLaWe1E7FA7VZSZ36XIXXb7e/HIrJ9BX5HdnOCnjSMJ1KOoBre3C61pBqm1V32 YmPRlp2uRhLL0FjwrWUVxETY7iX92EoS5+1U0eaa7/+bByeKRTjEF42qBpjR81HqGOvp znmF3/PLD5rqmkd4/Tq9jx/V5T8SW3nSRZ+y26HKOPELy+cLDiTfB2sZ6jDXl+qDToA5 NQCCtSeuyKv5PRooDzEmOucMBQynmCBJgT9ykxoS5o5P9NqNuZHLYk6Drn3lerYqCWKG OhVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=lnwnTjvDtK8rbLsKwHITGKosALgOjT8wquAyZlmPJFk=; b=ez1IqCB0mdQNiiRP16pQpqAc8DfkVIFXXWlgEnTFPEzunG8079DWxdU+5pMK0rIQYa fC9NzJD9vNCChzlfeEaqB0CfqWxWTiItg8Y+fDi0d8514dCMuU8HOx8ZIaZL7YUHT8Ta 7y1pFX8jyEctKVOwjHSaT+R4As44pu0MF/lUmCv3Jgt8PkDJ1lsRBO7alwK+FfxuZaAE f/Og/dEZTW0n8QIQ8Ry0k7yHjukPIce6n/TMsYL7YHiqXROdTiZvefKhYsuCtGWzwoxK 02b+TULHEmJ10IhOBBYkY8Ixr4+iYQ9CJ2I4Z3w6mvKeECeMstnghAJeYjJQHQHty6yT DNcA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37si40822667pgw.590.2018.11.20.09.03.13; Tue, 20 Nov 2018 09:03:42 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730323AbeKUDcK (ORCPT + 99 others); Tue, 20 Nov 2018 22:32:10 -0500 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:53200 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726281AbeKUDcK (ORCPT ); Tue, 20 Nov 2018 22:32:10 -0500 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id wAKGxTe9014706; Tue, 20 Nov 2018 11:01:54 -0600 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0a-001ae601.pphosted.com with ESMTP id 2nth984pd4-1; Tue, 20 Nov 2018 11:01:54 -0600 Received: from EX17.ad.cirrus.com (unknown [172.20.9.81]) by mail1.cirrus.com (Postfix) with ESMTP id 6B1D9611E125; Tue, 20 Nov 2018 11:01:53 -0600 (CST) Received: from imbe.wolfsonmicro.main (198.61.95.81) by EX17.ad.cirrus.com (172.20.9.81) with Microsoft SMTP Server id 14.3.408.0; Tue, 20 Nov 2018 17:01:52 +0000 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by imbe.wolfsonmicro.main (8.14.4/8.14.4) with ESMTP id wAKH1qfH008270; Tue, 20 Nov 2018 17:01:52 GMT From: Charles Keepax To: CC: , , , , Subject: [PATCH] regulator: wm8994: Don't use devres for enable GPIOs Date: Tue, 20 Nov 2018 17:01:52 +0000 Message-ID: <20181120170152.24652-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=816 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811200151 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need to manage the life time of the enable GPIO against the regulator device but the OF node lives on the parent MFD device. As such we can't use the devm functions which assume the same device will be used for both. Reported-by: Marek Szyprowski Signed-off-by: Charles Keepax --- This patch is only build tested so it would be good to get a tested by from Marek before applying. Thanks, Charles drivers/regulator/wm8994-regulator.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index d7fec533c403..f2592c30d0ca 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c @@ -31,6 +31,7 @@ struct wm8994_ldo { struct wm8994 *wm8994; struct regulator_consumer_supply supply; struct regulator_init_data init_data; + struct gpio_desc *ena_gpiod; }; #define WM8994_LDO1_MAX_SELECTOR 0x7 @@ -147,14 +148,19 @@ static int wm8994_ldo_probe(struct platform_device *pdev) config.regmap = wm8994->regmap; config.init_data = &ldo->init_data; - /* Look up LDO enable GPIO from the parent device node */ - gpiod = devm_gpiod_get_optional(pdev->dev.parent, - id ? "wlf,ldo2ena" : "wlf,ldo1ena", - GPIOD_OUT_LOW | - GPIOD_FLAGS_BIT_NONEXCLUSIVE); + /* + * Look up LDO enable GPIO from the parent device node, we can't + * use devm because it assumes the device we want to allocate + * against is the same one that holds the OF node + */ + gpiod = gpiod_get_optional(pdev->dev.parent, + id ? "wlf,ldo2ena" : "wlf,ldo1ena", + GPIOD_OUT_LOW | + GPIOD_FLAGS_BIT_NONEXCLUSIVE); if (IS_ERR(gpiod)) return PTR_ERR(gpiod); config.ena_gpiod = gpiod; + ldo->ena_gpiod = gpiod; /* Use default constraints if none set up */ if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) { @@ -184,11 +190,23 @@ static int wm8994_ldo_probe(struct platform_device *pdev) return 0; err: + gpiod_put(gpiod); return ret; } +static int wm8994_ldo_remove(struct platform_device *pdev) +{ + struct wm8994_ldo *ldo = platform_get_drvdata(pdev); + + if (ldo->ena_gpiod) + gpiod_put(ldo->ena_gpiod); + + return 0; +} + static struct platform_driver wm8994_ldo_driver = { .probe = wm8994_ldo_probe, + .remove = wm8994_ldo_remove, .driver = { .name = "wm8994-ldo", }, -- 2.11.0