Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5299048imm; Tue, 19 Jun 2018 08:12:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK1kGn3guEd8BuhSNr6PHjZBU9xu9eqfAH3dacdq9aLQRGRppz4uT2aeBihCALjF8O4ns+c X-Received: by 2002:a17:902:5a3:: with SMTP id f32-v6mr19102252plf.109.1529421177116; Tue, 19 Jun 2018 08:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529421177; cv=none; d=google.com; s=arc-20160816; b=VBw0UlWddNdVRCkbeQLq5LH+m6/iy98VTekjUCDyP499zjiPEHvD1xSIzKgMauAHiI GhrfZvqxWuh8DcYdI3XhkSGs0Jp+yN6y0OPHFnRkxGnU676a4kBMEobQxUr/IiYxmP9k xaLm5P78ldxr3bQ4ypk7cIP/Lj80aDEA7DBCwgy2jLS9fU45IWlNrIwytWdog6BIdrMm X4EBneYfmrOHBDFRiQGT0tW2/bQDSlLXUxJbEw0J1l7OYApGaCVYjs0r9zYDsLGSWmd1 XJpsjRcZ/wUZZo1nz/K+SeobOUnxMpK5/8wl1cLUY5ly7+Shn4C4WUdXJlXWR7uELCyp aEpw== 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:arc-authentication-results; bh=6EgT5DT3YUmbNS2K6iOU6UBSwkApz4tHJn+GOFJS9Is=; b=tR8LV7Y1WhYEMjdxTQ6UAVuAYfvE0y4amF5orm3uVHNnJj1/A5E3ZxZRMsIcMGGoF/ X2yiPKlvrF7QKVfc9CKcsgUfQJsZBBG8Ge/9q79++KgutJqJY4CFVQdjIBXcBsNqoEJX rE5aO0Be24gCoOeIXdew7lIIv/muC3A44TY8WkqpRIuDBt+/rZiERKCCW/uWSVpseOHO F4RSBZABDC50i1ELA2fz3ab6yzeZllbnymGlseqdFlXLOj05cJ4oKk3vYSqM9MnRuRBh BNvPOwlUf6IuRJQGmdawwHcaATklZ0TowhaYngz1G8LnHa+mCiwQqxvirZiM1v5yH5CM stDQ== 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 w21-v6si14246624pgv.462.2018.06.19.08.12.19; Tue, 19 Jun 2018 08:12:57 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966468AbeFSPKW (ORCPT + 99 others); Tue, 19 Jun 2018 11:10:22 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:45800 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S937365AbeFSPKW (ORCPT ); Tue, 19 Jun 2018 11:10:22 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5JF4MFC011120; Tue, 19 Jun 2018 10:10:02 -0500 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail3.cirrus.com ([87.246.76.56]) by mx0a-001ae601.pphosted.com with ESMTP id 2jmyy2d7wt-1; Tue, 19 Jun 2018 10:10:02 -0500 Received: from EX17.ad.cirrus.com (ex17.ad.cirrus.com [172.20.9.81]) by mail3.cirrus.com (Postfix) with ESMTP id B7C296255C63; Tue, 19 Jun 2018 10:10:47 -0500 (CDT) 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.301.0; Tue, 19 Jun 2018 16:10:01 +0100 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 w5JFA03B016890; Tue, 19 Jun 2018 16:10:00 +0100 From: Charles Keepax To: , CC: , , , Subject: [PATCH v2] regulator: arizona-ldo1: Use correct device to get enable GPIO Date: Tue, 19 Jun 2018 16:10:00 +0100 Message-ID: <20180619151000.21693-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=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=777 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806190169 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes since v1: - Pass GPIOD_OUT_LOW to gpiod_get_optional 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..e976d073f28d 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_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(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