Commit 3227e04e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'regulator-v3.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator fixes from Mark Brown:
 "Mostly driver specific fixes here, though one of them uncovered the
  issue Stephen Warren fixed with multiple OF matches getting upset due
  to a lack of cleanup."

* tag 'regulator-v3.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
  regulator: s2mps11: fix incorrect register for buck10
  regulator: clear state each invocation of of_regulator_match
  regulator: max8997: Fix using wrong dev argument at various places
  regulator: max77686: Fix using wrong dev argument at various places
  regulator: max8907: Fix using wrong dev argument for calling of_regulator_match
  regulator: max8998: fix incorrect min_uV value for ldo10
  regulator: tps65910: Fix using wrong dev argument for calling of_regulator_match
  regulator: tps65217: Fix using wrong dev argument for calling of_regulator_match
parents 6bacaa9d 53e5da79
...@@ -379,9 +379,10 @@ static struct regulator_desc regulators[] = { ...@@ -379,9 +379,10 @@ static struct regulator_desc regulators[] = {
}; };
#ifdef CONFIG_OF #ifdef CONFIG_OF
static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev, static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
struct max77686_platform_data *pdata) struct max77686_platform_data *pdata)
{ {
struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct device_node *pmic_np, *regulators_np; struct device_node *pmic_np, *regulators_np;
struct max77686_regulator_data *rdata; struct max77686_regulator_data *rdata;
struct of_regulator_match rmatch; struct of_regulator_match rmatch;
...@@ -390,15 +391,15 @@ static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev, ...@@ -390,15 +391,15 @@ static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev,
pmic_np = iodev->dev->of_node; pmic_np = iodev->dev->of_node;
regulators_np = of_find_node_by_name(pmic_np, "voltage-regulators"); regulators_np = of_find_node_by_name(pmic_np, "voltage-regulators");
if (!regulators_np) { if (!regulators_np) {
dev_err(iodev->dev, "could not find regulators sub-node\n"); dev_err(&pdev->dev, "could not find regulators sub-node\n");
return -EINVAL; return -EINVAL;
} }
pdata->num_regulators = ARRAY_SIZE(regulators); pdata->num_regulators = ARRAY_SIZE(regulators);
rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
pdata->num_regulators, GFP_KERNEL); pdata->num_regulators, GFP_KERNEL);
if (!rdata) { if (!rdata) {
dev_err(iodev->dev, dev_err(&pdev->dev,
"could not allocate memory for regulator data\n"); "could not allocate memory for regulator data\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -407,7 +408,7 @@ static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev, ...@@ -407,7 +408,7 @@ static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev,
rmatch.name = regulators[i].name; rmatch.name = regulators[i].name;
rmatch.init_data = NULL; rmatch.init_data = NULL;
rmatch.of_node = NULL; rmatch.of_node = NULL;
of_regulator_match(iodev->dev, regulators_np, &rmatch, 1); of_regulator_match(&pdev->dev, regulators_np, &rmatch, 1);
rdata[i].initdata = rmatch.init_data; rdata[i].initdata = rmatch.init_data;
rdata[i].of_node = rmatch.of_node; rdata[i].of_node = rmatch.of_node;
} }
...@@ -417,7 +418,7 @@ static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev, ...@@ -417,7 +418,7 @@ static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev,
return 0; return 0;
} }
#else #else
static int max77686_pmic_dt_parse_pdata(struct max77686_dev *iodev, static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
struct max77686_platform_data *pdata) struct max77686_platform_data *pdata)
{ {
return 0; return 0;
...@@ -440,7 +441,7 @@ static int max77686_pmic_probe(struct platform_device *pdev) ...@@ -440,7 +441,7 @@ static int max77686_pmic_probe(struct platform_device *pdev)
} }
if (iodev->dev->of_node) { if (iodev->dev->of_node) {
ret = max77686_pmic_dt_parse_pdata(iodev, pdata); ret = max77686_pmic_dt_parse_pdata(pdev, pdata);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -237,8 +237,7 @@ static int max8907_regulator_parse_dt(struct platform_device *pdev) ...@@ -237,8 +237,7 @@ static int max8907_regulator_parse_dt(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
ret = of_regulator_match(pdev->dev.parent, regulators, ret = of_regulator_match(&pdev->dev, regulators, max8907_matches,
max8907_matches,
ARRAY_SIZE(max8907_matches)); ARRAY_SIZE(max8907_matches));
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", dev_err(&pdev->dev, "Error parsing regulator init data: %d\n",
......
...@@ -934,7 +934,7 @@ static struct regulator_desc regulators[] = { ...@@ -934,7 +934,7 @@ static struct regulator_desc regulators[] = {
}; };
#ifdef CONFIG_OF #ifdef CONFIG_OF
static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev, static int max8997_pmic_dt_parse_dvs_gpio(struct platform_device *pdev,
struct max8997_platform_data *pdata, struct max8997_platform_data *pdata,
struct device_node *pmic_np) struct device_node *pmic_np)
{ {
...@@ -944,7 +944,7 @@ static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev, ...@@ -944,7 +944,7 @@ static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev,
gpio = of_get_named_gpio(pmic_np, gpio = of_get_named_gpio(pmic_np,
"max8997,pmic-buck125-dvs-gpios", i); "max8997,pmic-buck125-dvs-gpios", i);
if (!gpio_is_valid(gpio)) { if (!gpio_is_valid(gpio)) {
dev_err(iodev->dev, "invalid gpio[%d]: %d\n", i, gpio); dev_err(&pdev->dev, "invalid gpio[%d]: %d\n", i, gpio);
return -EINVAL; return -EINVAL;
} }
pdata->buck125_gpios[i] = gpio; pdata->buck125_gpios[i] = gpio;
...@@ -952,22 +952,23 @@ static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev, ...@@ -952,22 +952,23 @@ static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev,
return 0; return 0;
} }
static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
struct max8997_platform_data *pdata) struct max8997_platform_data *pdata)
{ {
struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct device_node *pmic_np, *regulators_np, *reg_np; struct device_node *pmic_np, *regulators_np, *reg_np;
struct max8997_regulator_data *rdata; struct max8997_regulator_data *rdata;
unsigned int i, dvs_voltage_nr = 1, ret; unsigned int i, dvs_voltage_nr = 1, ret;
pmic_np = iodev->dev->of_node; pmic_np = iodev->dev->of_node;
if (!pmic_np) { if (!pmic_np) {
dev_err(iodev->dev, "could not find pmic sub-node\n"); dev_err(&pdev->dev, "could not find pmic sub-node\n");
return -ENODEV; return -ENODEV;
} }
regulators_np = of_find_node_by_name(pmic_np, "regulators"); regulators_np = of_find_node_by_name(pmic_np, "regulators");
if (!regulators_np) { if (!regulators_np) {
dev_err(iodev->dev, "could not find regulators sub-node\n"); dev_err(&pdev->dev, "could not find regulators sub-node\n");
return -EINVAL; return -EINVAL;
} }
...@@ -976,11 +977,10 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, ...@@ -976,11 +977,10 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
for_each_child_of_node(regulators_np, reg_np) for_each_child_of_node(regulators_np, reg_np)
pdata->num_regulators++; pdata->num_regulators++;
rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
pdata->num_regulators, GFP_KERNEL); pdata->num_regulators, GFP_KERNEL);
if (!rdata) { if (!rdata) {
dev_err(iodev->dev, "could not allocate memory for " dev_err(&pdev->dev, "could not allocate memory for regulator data\n");
"regulator data\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -991,14 +991,14 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, ...@@ -991,14 +991,14 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
break; break;
if (i == ARRAY_SIZE(regulators)) { if (i == ARRAY_SIZE(regulators)) {
dev_warn(iodev->dev, "don't know how to configure " dev_warn(&pdev->dev, "don't know how to configure regulator %s\n",
"regulator %s\n", reg_np->name); reg_np->name);
continue; continue;
} }
rdata->id = i; rdata->id = i;
rdata->initdata = of_get_regulator_init_data( rdata->initdata = of_get_regulator_init_data(&pdev->dev,
iodev->dev, reg_np); reg_np);
rdata->reg_node = reg_np; rdata->reg_node = reg_np;
rdata++; rdata++;
} }
...@@ -1014,7 +1014,7 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, ...@@ -1014,7 +1014,7 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs || if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs ||
pdata->buck5_gpiodvs) { pdata->buck5_gpiodvs) {
ret = max8997_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); ret = max8997_pmic_dt_parse_dvs_gpio(pdev, pdata, pmic_np);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
...@@ -1025,8 +1025,7 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, ...@@ -1025,8 +1025,7 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
} else { } else {
if (pdata->buck125_default_idx >= 8) { if (pdata->buck125_default_idx >= 8) {
pdata->buck125_default_idx = 0; pdata->buck125_default_idx = 0;
dev_info(iodev->dev, "invalid value for " dev_info(&pdev->dev, "invalid value for default dvs index, using 0 instead\n");
"default dvs index, using 0 instead\n");
} }
} }
...@@ -1040,28 +1039,28 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, ...@@ -1040,28 +1039,28 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
if (of_property_read_u32_array(pmic_np, if (of_property_read_u32_array(pmic_np,
"max8997,pmic-buck1-dvs-voltage", "max8997,pmic-buck1-dvs-voltage",
pdata->buck1_voltage, dvs_voltage_nr)) { pdata->buck1_voltage, dvs_voltage_nr)) {
dev_err(iodev->dev, "buck1 voltages not specified\n"); dev_err(&pdev->dev, "buck1 voltages not specified\n");
return -EINVAL; return -EINVAL;
} }
if (of_property_read_u32_array(pmic_np, if (of_property_read_u32_array(pmic_np,
"max8997,pmic-buck2-dvs-voltage", "max8997,pmic-buck2-dvs-voltage",
pdata->buck2_voltage, dvs_voltage_nr)) { pdata->buck2_voltage, dvs_voltage_nr)) {
dev_err(iodev->dev, "buck2 voltages not specified\n"); dev_err(&pdev->dev, "buck2 voltages not specified\n");
return -EINVAL; return -EINVAL;
} }
if (of_property_read_u32_array(pmic_np, if (of_property_read_u32_array(pmic_np,
"max8997,pmic-buck5-dvs-voltage", "max8997,pmic-buck5-dvs-voltage",
pdata->buck5_voltage, dvs_voltage_nr)) { pdata->buck5_voltage, dvs_voltage_nr)) {
dev_err(iodev->dev, "buck5 voltages not specified\n"); dev_err(&pdev->dev, "buck5 voltages not specified\n");
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
} }
#else #else
static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
struct max8997_platform_data *pdata) struct max8997_platform_data *pdata)
{ {
return 0; return 0;
...@@ -1085,7 +1084,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) ...@@ -1085,7 +1084,7 @@ static int max8997_pmic_probe(struct platform_device *pdev)
} }
if (iodev->dev->of_node) { if (iodev->dev->of_node) {
ret = max8997_pmic_dt_parse_pdata(iodev, pdata); ret = max8997_pmic_dt_parse_pdata(pdev, pdata);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -65,7 +65,7 @@ static const struct voltage_map_desc ldo9_voltage_map_desc = { ...@@ -65,7 +65,7 @@ static const struct voltage_map_desc ldo9_voltage_map_desc = {
.min = 2800000, .step = 100000, .max = 3100000, .min = 2800000, .step = 100000, .max = 3100000,
}; };
static const struct voltage_map_desc ldo10_voltage_map_desc = { static const struct voltage_map_desc ldo10_voltage_map_desc = {
.min = 95000, .step = 50000, .max = 1300000, .min = 950000, .step = 50000, .max = 1300000,
}; };
static const struct voltage_map_desc ldo1213_voltage_map_desc = { static const struct voltage_map_desc ldo1213_voltage_map_desc = {
.min = 800000, .step = 100000, .max = 3300000, .min = 800000, .step = 100000, .max = 3300000,
......
...@@ -120,6 +120,12 @@ int of_regulator_match(struct device *dev, struct device_node *node, ...@@ -120,6 +120,12 @@ int of_regulator_match(struct device *dev, struct device_node *node,
if (!dev || !node) if (!dev || !node)
return -EINVAL; return -EINVAL;
for (i = 0; i < num_matches; i++) {
struct of_regulator_match *match = &matches[i];
match->init_data = NULL;
match->of_node = NULL;
}
for_each_child_of_node(node, child) { for_each_child_of_node(node, child) {
name = of_get_property(child, name = of_get_property(child,
"regulator-compatible", NULL); "regulator-compatible", NULL);
......
...@@ -174,9 +174,9 @@ static struct regulator_ops s2mps11_buck_ops = { ...@@ -174,9 +174,9 @@ static struct regulator_ops s2mps11_buck_ops = {
.min_uV = S2MPS11_BUCK_MIN2, \ .min_uV = S2MPS11_BUCK_MIN2, \
.uV_step = S2MPS11_BUCK_STEP2, \ .uV_step = S2MPS11_BUCK_STEP2, \
.n_voltages = S2MPS11_BUCK_N_VOLTAGES, \ .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
.vsel_reg = S2MPS11_REG_B9CTRL2, \ .vsel_reg = S2MPS11_REG_B10CTRL2, \
.vsel_mask = S2MPS11_BUCK_VSEL_MASK, \ .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
.enable_reg = S2MPS11_REG_B9CTRL1, \ .enable_reg = S2MPS11_REG_B10CTRL1, \
.enable_mask = S2MPS11_ENABLE_MASK \ .enable_mask = S2MPS11_ENABLE_MASK \
} }
......
...@@ -305,8 +305,8 @@ static struct tps65217_board *tps65217_parse_dt(struct platform_device *pdev) ...@@ -305,8 +305,8 @@ static struct tps65217_board *tps65217_parse_dt(struct platform_device *pdev)
if (!regs) if (!regs)
return NULL; return NULL;
count = of_regulator_match(pdev->dev.parent, regs, count = of_regulator_match(&pdev->dev, regs, reg_matches,
reg_matches, TPS65217_NUM_REGULATOR); TPS65217_NUM_REGULATOR);
of_node_put(regs); of_node_put(regs);
if ((count < 0) || (count > TPS65217_NUM_REGULATOR)) if ((count < 0) || (count > TPS65217_NUM_REGULATOR))
return NULL; return NULL;
......
...@@ -998,7 +998,7 @@ static struct tps65910_board *tps65910_parse_dt_reg_data( ...@@ -998,7 +998,7 @@ static struct tps65910_board *tps65910_parse_dt_reg_data(
return NULL; return NULL;
} }
ret = of_regulator_match(pdev->dev.parent, regulators, matches, count); ret = of_regulator_match(&pdev->dev, regulators, matches, count);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", dev_err(&pdev->dev, "Error parsing regulator init data: %d\n",
ret); ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment