From: Hans de Goede <hdegoede@redhat.com>
To: Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Chen-Yu Tsai <wens@csie.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Hans de Goede <hdegoede@redhat.com>
Subject: [PATCH 1/2] regulator: core: Allow use of "status = disabled" in regulator dts nodes
Date: Wed, 27 Apr 2016 16:03:44 +0200 [thread overview]
Message-ID: <1461765825-15915-2-git-send-email-hdegoede@redhat.com> (raw)
In-Reply-To: <1461765825-15915-1-git-send-email-hdegoede@redhat.com>
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 <hdegoede@redhat.com>
---
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 e0b7642..8062c83 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3911,6 +3911,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 6b0aa80..7af6e17 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -315,7 +315,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;
--
2.7.4
next prev parent reply other threads:[~2016-04-27 14:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-27 14:03 [PATCH resend 0/2] regulator: core: Allow use of "status = disabled" in regulator dts nodes Hans de Goede
2016-04-27 14:03 ` Hans de Goede [this message]
2016-04-27 14:24 ` [PATCH 1/2] " Mark Brown
2016-04-27 14:31 ` Hans de Goede
2016-04-27 14:37 ` Mark Brown
2016-04-27 14:40 ` Hans de Goede
2016-04-27 15:01 ` Mark Brown
2016-04-27 15:50 ` Maxime Ripard
2016-04-27 15:52 ` Hans de Goede
2016-04-27 15:54 ` Hans de Goede
2016-04-27 16:32 ` Mark Brown
2016-04-27 14:03 ` [PATCH 2/2] regulator: axp20x: Handle regulator_register returning ENODEV Hans de Goede
2016-04-27 14:25 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461765825-15915-2-git-send-email-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).