Skip to content

Commit 35e21de

Browse files
jbrun3tbroonie
authored andcommitted
regulator: core: let dt properties override driver init_data
This reverts commit cd7a38c. When submitting the change above, it was thought that the origin of the init_data should be a clear choice, from the driver or from DT but not both. It turns out some devices, such as qcom-msm8974-lge-nexus5-hammerhead, relied on the old behaviour to override the init_data provided by the driver, making it some kind of default if none is provided by the platform. Using the init_data provided by the driver when it is present broke these devices so revert the change to fixup the situation and add a comment to make things a bit more clear Reported-by: Luca Weiss <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected] Fixes: cd7a38c ("regulator: core: do not silently ignore provided init_data") Signed-off-by: Jerome Brunet <[email protected]> Link: https://patch.msgid.link/20250211-regulator-init-data-fixup-v1-1-5ce1c6cff990@baylibre.com Signed-off-by: Mark Brown <[email protected]>
1 parent b0eddc2 commit 35e21de

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

drivers/regulator/core.c

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5774,43 +5774,36 @@ regulator_register(struct device *dev,
57745774
goto clean;
57755775
}
57765776

5777-
if (config->init_data) {
5778-
/*
5779-
* Providing of_match means the framework is expected to parse
5780-
* DT to get the init_data. This would conflict with provided
5781-
* init_data, if set. Warn if it happens.
5782-
*/
5783-
if (regulator_desc->of_match)
5784-
dev_warn(dev, "Using provided init data - OF match ignored\n");
5777+
/*
5778+
* DT may override the config->init_data provided if the platform
5779+
* needs to do so. If so, config->init_data is completely ignored.
5780+
*/
5781+
init_data = regulator_of_get_init_data(dev, regulator_desc, config,
5782+
&rdev->dev.of_node);
57855783

5784+
/*
5785+
* Sometimes not all resources are probed already so we need to take
5786+
* that into account. This happens most the time if the ena_gpiod comes
5787+
* from a gpio extender or something else.
5788+
*/
5789+
if (PTR_ERR(init_data) == -EPROBE_DEFER) {
5790+
ret = -EPROBE_DEFER;
5791+
goto clean;
5792+
}
5793+
5794+
/*
5795+
* We need to keep track of any GPIO descriptor coming from the
5796+
* device tree until we have handled it over to the core. If the
5797+
* config that was passed in to this function DOES NOT contain
5798+
* a descriptor, and the config after this call DOES contain
5799+
* a descriptor, we definitely got one from parsing the device
5800+
* tree.
5801+
*/
5802+
if (!cfg->ena_gpiod && config->ena_gpiod)
5803+
dangling_of_gpiod = true;
5804+
if (!init_data) {
57865805
init_data = config->init_data;
57875806
rdev->dev.of_node = of_node_get(config->of_node);
5788-
5789-
} else {
5790-
init_data = regulator_of_get_init_data(dev, regulator_desc,
5791-
config,
5792-
&rdev->dev.of_node);
5793-
5794-
/*
5795-
* Sometimes not all resources are probed already so we need to
5796-
* take that into account. This happens most the time if the
5797-
* ena_gpiod comes from a gpio extender or something else.
5798-
*/
5799-
if (PTR_ERR(init_data) == -EPROBE_DEFER) {
5800-
ret = -EPROBE_DEFER;
5801-
goto clean;
5802-
}
5803-
5804-
/*
5805-
* We need to keep track of any GPIO descriptor coming from the
5806-
* device tree until we have handled it over to the core. If the
5807-
* config that was passed in to this function DOES NOT contain a
5808-
* descriptor, and the config after this call DOES contain a
5809-
* descriptor, we definitely got one from parsing the device
5810-
* tree.
5811-
*/
5812-
if (!cfg->ena_gpiod && config->ena_gpiod)
5813-
dangling_of_gpiod = true;
58145807
}
58155808

58165809
ww_mutex_init(&rdev->mutex, &regulator_ww_class);

0 commit comments

Comments
 (0)