aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-09-24 15:25:00 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-25 08:44:47 -0400
commit13511def87b9f68697a0fc4c64ddacece585a471 (patch)
treebd3dbf02ab5a04d1e09c71fa6b6c982f1669f248
parent3b26e48308feaf428efb917f8de217797bfedb26 (diff)
regulator: deprecate regulator-compatible DT property
When the bindings for the TPS6586x regulator were being proposed, I asserted that DT node naming rules for bus child nodes should also be applied to nodes inside the TPS6586x regulator node itself. In other words, that each node providing regulator init data should be named after the type of object it represented ("regulator") and hence that some other property was required to indicate which regulator the node described ("regulator-compatible"). In turn this led to multiple nodes having the same name, thus requiring node names to use a unit address to make them unique, thus requiring reg properties within the nodes and However, subsequent discussion indicates that the rules I was asserting only applies to standardized bus nodes, and within a device's own node, the binding can basically do anything sane that it wants. Hence, this change deprecates the register-compatible property, and instead uses node names to replace this functionality. This greatly simplifies the device tree content, making them smaller and more legible. The code is changed such that old device trees continue to work. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--Documentation/devicetree/bindings/regulator/regulator.txt5
-rw-r--r--drivers/regulator/of_regulator.c25
2 files changed, 16 insertions, 14 deletions
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt
index 66ece3f87bbc..ecfc6ccd67ef 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -11,10 +11,13 @@ Optional properties:
11- regulator-boot-on: bootloader/firmware enabled regulator 11- regulator-boot-on: bootloader/firmware enabled regulator
12- <name>-supply: phandle to the parent supply/regulator node 12- <name>-supply: phandle to the parent supply/regulator node
13- regulator-ramp-delay: ramp delay for regulator(in uV/uS) 13- regulator-ramp-delay: ramp delay for regulator(in uV/uS)
14
15Deprecated properties:
14- regulator-compatible: If a regulator chip contains multiple 16- regulator-compatible: If a regulator chip contains multiple
15 regulators, and if the chip's binding contains a child node that 17 regulators, and if the chip's binding contains a child node that
16 describes each regulator, then this property indicates which regulator 18 describes each regulator, then this property indicates which regulator
17 this child node is intended to configure. 19 this child node is intended to configure. If this property is missing,
20 the node's name will be used instead.
18 21
19Example: 22Example:
20 23
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 3e4106f2bda9..6f684916fd79 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -92,16 +92,18 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
92EXPORT_SYMBOL_GPL(of_get_regulator_init_data); 92EXPORT_SYMBOL_GPL(of_get_regulator_init_data);
93 93
94/** 94/**
95 * of_regulator_match - extract regulator init data when node 95 * of_regulator_match - extract multiple regulator init data from device tree.
96 * property "regulator-compatible" matches with the regulator name.
97 * @dev: device requesting the data 96 * @dev: device requesting the data
98 * @node: parent device node of the regulators 97 * @node: parent device node of the regulators
99 * @matches: match table for the regulators 98 * @matches: match table for the regulators
100 * @num_matches: number of entries in match table 99 * @num_matches: number of entries in match table
101 * 100 *
102 * This function uses a match table specified by the regulator driver and 101 * This function uses a match table specified by the regulator driver to
103 * looks up the corresponding init data in the device tree if 102 * parse regulator init data from the device tree. @node is expected to
104 * regulator-compatible matches. Note that the match table is modified 103 * contain a set of child nodes, each providing the init data for one
104 * regulator. The data parsed from a child node will be matched to a regulator
105 * based on either the deprecated property regulator-compatible if present,
106 * or otherwise the child node's name. Note that the match table is modified
105 * in place. 107 * in place.
106 * 108 *
107 * Returns the number of matches found or a negative error code on failure. 109 * Returns the number of matches found or a negative error code on failure.
@@ -112,26 +114,23 @@ int of_regulator_match(struct device *dev, struct device_node *node,
112{ 114{
113 unsigned int count = 0; 115 unsigned int count = 0;
114 unsigned int i; 116 unsigned int i;
115 const char *regulator_comp; 117 const char *name;
116 struct device_node *child; 118 struct device_node *child;
117 119
118 if (!dev || !node) 120 if (!dev || !node)
119 return -EINVAL; 121 return -EINVAL;
120 122
121 for_each_child_of_node(node, child) { 123 for_each_child_of_node(node, child) {
122 regulator_comp = of_get_property(child, 124 name = of_get_property(child,
123 "regulator-compatible", NULL); 125 "regulator-compatible", NULL);
124 if (!regulator_comp) { 126 if (!name)
125 dev_err(dev, "regulator-compatible is missing for node %s\n", 127 name = child->name;
126 child->name);
127 continue;
128 }
129 for (i = 0; i < num_matches; i++) { 128 for (i = 0; i < num_matches; i++) {
130 struct of_regulator_match *match = &matches[i]; 129 struct of_regulator_match *match = &matches[i];
131 if (match->of_node) 130 if (match->of_node)
132 continue; 131 continue;
133 132
134 if (strcmp(match->name, regulator_comp)) 133 if (strcmp(match->name, name))
135 continue; 134 continue;
136 135
137 match->init_data = 136 match->init_data =