Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'topic/of' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-isl9305

+66 -3
+7 -3
drivers/regulator/core.c
··· 3553 3553 return ERR_PTR(-EINVAL); 3554 3554 } 3555 3555 3556 - init_data = config->init_data; 3557 - 3558 3556 rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL); 3559 3557 if (rdev == NULL) 3560 3558 return ERR_PTR(-ENOMEM); 3559 + 3560 + init_data = regulator_of_get_init_data(dev, regulator_desc, 3561 + &rdev->dev.of_node); 3562 + if (!init_data) { 3563 + init_data = config->init_data; 3564 + rdev->dev.of_node = of_node_get(config->of_node); 3565 + } 3561 3566 3562 3567 mutex_lock(&regulator_list_mutex); 3563 3568 ··· 3590 3585 3591 3586 /* register with sysfs */ 3592 3587 rdev->dev.class = &regulator_class; 3593 - rdev->dev.of_node = of_node_get(config->of_node); 3594 3588 rdev->dev.parent = dev; 3595 3589 dev_set_name(&rdev->dev, "regulator.%d", 3596 3590 atomic_inc_return(&regulator_no) - 1);
+4
drivers/regulator/internal.h
··· 35 35 struct dentry *debugfs; 36 36 }; 37 37 38 + struct regulator_init_data *regulator_of_get_init_data(struct device *dev, 39 + const struct regulator_desc *desc, 40 + struct device_node **node); 41 + 38 42 #endif
+51
drivers/regulator/of_regulator.c
··· 14 14 #include <linux/slab.h> 15 15 #include <linux/of.h> 16 16 #include <linux/regulator/machine.h> 17 + #include <linux/regulator/driver.h> 17 18 #include <linux/regulator/of_regulator.h> 19 + 20 + #include "internal.h" 18 21 19 22 static void of_get_regulation_constraints(struct device_node *np, 20 23 struct regulator_init_data **init_data) ··· 192 189 return count; 193 190 } 194 191 EXPORT_SYMBOL_GPL(of_regulator_match); 192 + 193 + struct regulator_init_data *regulator_of_get_init_data(struct device *dev, 194 + const struct regulator_desc *desc, 195 + struct device_node **node) 196 + { 197 + struct device_node *search, *child; 198 + struct regulator_init_data *init_data = NULL; 199 + const char *name; 200 + 201 + if (!dev->of_node || !desc->of_match) 202 + return NULL; 203 + 204 + if (desc->regulators_node) 205 + search = of_get_child_by_name(dev->of_node, 206 + desc->regulators_node); 207 + else 208 + search = dev->of_node; 209 + 210 + if (!search) { 211 + dev_err(dev, "Failed to find regulator container node\n"); 212 + return NULL; 213 + } 214 + 215 + for_each_child_of_node(search, child) { 216 + name = of_get_property(child, "regulator-compatible", NULL); 217 + if (!name) 218 + name = child->name; 219 + 220 + if (strcmp(desc->of_match, name)) 221 + continue; 222 + 223 + init_data = of_get_regulator_init_data(dev, child); 224 + if (!init_data) { 225 + dev_err(dev, 226 + "failed to parse DT for regulator %s\n", 227 + child->name); 228 + break; 229 + } 230 + 231 + of_node_get(child); 232 + *node = child; 233 + break; 234 + } 235 + 236 + of_node_put(search); 237 + 238 + return init_data; 239 + }
+4
include/linux/regulator/driver.h
··· 203 203 * 204 204 * @name: Identifying name for the regulator. 205 205 * @supply_name: Identifying the regulator supply 206 + * @of_match: Name used to identify regulator in DT. 207 + * @regulators_node: Name of node containing regulator definitions in DT. 206 208 * @id: Numerical identifier for the regulator. 207 209 * @ops: Regulator operations table. 208 210 * @irq: Interrupt number for the regulator. ··· 245 243 struct regulator_desc { 246 244 const char *name; 247 245 const char *supply_name; 246 + const char *of_match; 247 + const char *regulators_node; 248 248 int id; 249 249 bool continuous_voltage_range; 250 250 unsigned n_voltages;