From patchwork Fri Mar 11 21:01:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 8569131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70FE3C0553 for ; Fri, 11 Mar 2016 21:03:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 857322034A for ; Fri, 11 Mar 2016 21:03:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5B28202B8 for ; Fri, 11 Mar 2016 21:03:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aeUBx-0005V6-Nw; Fri, 11 Mar 2016 21:01:49 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aeUBl-0005Ff-Mw for linux-arm-kernel@lists.infradead.org; Fri, 11 Mar 2016 21:01:38 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 1A5B1461C1; Fri, 11 Mar 2016 21:01:17 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-6-20.ams2.redhat.com [10.36.6.20]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2BL1Cmp008764; Fri, 11 Mar 2016 16:01:13 -0500 From: Hans de Goede To: Maxime Ripard , Chen-Yu Tsai , Mark Brown , Liam Girdwood Subject: [PATCH 1/3] regulator: core: Allow use of "status = disabled" in regulator dts nodes Date: Fri, 11 Mar 2016 22:01:07 +0100 Message-Id: <1457730069-31760-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160311_130137_812239_6E72332F X-CRM114-Status: GOOD ( 15.11 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree , linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org, Hans de Goede MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The axp20x and axp22x pmics have ldo regulators which are muxed to the outside via gpio pins. Unfortunately regulator enable / disable is implemented in the hardware via selecting a specific pin-mux option. So if we want to use these pins as gpio pins we must not register a regulator for these pins at all, otherwise any gpio use (switching to input, or writing a value) gets undone when the regulator subsys disables unused regulators at the end of kernel-init. This commits allows the use of "status = disabled" in regulator dts nodes and makes regulator_register return ENODEV when this is set. Note that this commit changes the loop to find the of-node in regulator_of_get_init_data from using for_each_available_child_of_node to using for_each_child_of_node. regulator_register is the only user of regulator_of_get_init_data and the use of for_each_available_child... makes little sense there since this will only cause the constraints from regulator dts nodes marked as disabled to not be used, the actual registration of the regulator would still continue. So in a way this patch could be seen as a bugfix as it actually makes regulators with an of_node which is marked as not available not register, but this behavior change may cause some issues in some places. Note that individual regulator drivers / callers of regulator_register which may encounter disabled regulator (child) nodes need to be patched to handle ENODEV (to not make it fail their probe method). Signed-off-by: Hans de Goede --- drivers/regulator/core.c | 6 ++++++ drivers/regulator/of_regulator.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 744c988..5589203 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3894,6 +3894,12 @@ regulator_register(const struct regulator_desc *regulator_desc, rdev->dev.of_node = of_node_get(config->of_node); } + if (rdev->dev.of_node && !of_device_is_available(rdev->dev.of_node)) { + kfree(config); + kfree(rdev); + return ERR_PTR(-ENODEV); + } + mutex_lock(®ulator_list_mutex); mutex_init(&rdev->mutex); diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 499e437..06ad766 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -310,7 +310,7 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev, return NULL; } - for_each_available_child_of_node(search, child) { + for_each_child_of_node(search, child) { name = of_get_property(child, "regulator-compatible", NULL); if (!name) name = child->name;