“dbf3e950679b2588e554baa4da94c445c7903e24”上不存在“arch/sparc/kernel/traps_64.c”
提交 469b640e 编写于 作者: B Boris Brezillon 提交者: Mark Brown

regulator: reorder initialization steps in regulator_register()

device_register() is calling ->get_voltage() as part of it's sysfs attribute
initialization process, and this functions might need to know the regulator
constraints to return a valid value.
This is at least true for the pwm regulator driver (when operating in
continuous mode) which needs to know the minimum and maximum voltage values
to calculate the current voltage:

min_uV + (((max_uV - min_uV) * dutycycle) / 100);

Move device_register() after set_machine_constraints() to make sure those
constraints are correctly initialized when ->get_voltage() is called.
Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com>
Reported-by: NStephen Barber <smbarber@chromium.org>
Tested-by: NCaesar Wang <wxt@rock-chips.com>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 f55532a0
......@@ -3950,13 +3950,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
rdev->dev.parent = dev;
dev_set_name(&rdev->dev, "regulator.%lu",
(unsigned long) atomic_inc_return(&regulator_no));
ret = device_register(&rdev->dev);
if (ret != 0) {
put_device(&rdev->dev);
goto wash;
}
dev_set_drvdata(&rdev->dev, rdev);
/* set regulator constraints */
if (init_data)
......@@ -3964,7 +3957,15 @@ regulator_register(const struct regulator_desc *regulator_desc,
ret = set_machine_constraints(rdev, constraints);
if (ret < 0)
goto scrub;
goto wash;
ret = device_register(&rdev->dev);
if (ret != 0) {
put_device(&rdev->dev);
goto wash;
}
dev_set_drvdata(&rdev->dev, rdev);
if (init_data && init_data->supply_regulator)
rdev->supply_name = init_data->supply_regulator;
......@@ -3993,8 +3994,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
unset_supplies:
unset_regulator_supplies(rdev);
scrub:
regulator_ena_gpio_free(rdev);
device_unregister(&rdev->dev);
/* device core frees rdev */
......@@ -4002,6 +4001,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
goto out;
wash:
kfree(rdev->constraints);
regulator_ena_gpio_free(rdev);
clean:
kfree(rdev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册