Unverified Commit 35e21de4 authored by Jerome Brunet's avatar Jerome Brunet Committed by Mark Brown
Browse files

regulator: core: let dt properties override driver init_data



This reverts commit cd7a38c4.

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: default avatarLuca Weiss <luca@lucaweiss.eu>
Closes: https://lore.kernel.org/lkml/5857103.DvuYhMxLoT@lucaweiss.eu


Fixes: cd7a38c4 ("regulator: core: do not silently ignore provided init_data")
Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Link: https://patch.msgid.link/20250211-regulator-init-data-fixup-v1-1-5ce1c6cff990@baylibre.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent b0eddc21
Loading
Loading
Loading
Loading
+27 −34
Original line number Diff line number Diff line
@@ -5774,27 +5774,17 @@ regulator_register(struct device *dev,
		goto clean;
	}

	if (config->init_data) {
	/*
		 * Providing of_match means the framework is expected to parse
		 * DT to get the init_data. This would conflict with provided
		 * init_data, if set. Warn if it happens.
	 * DT may override the config->init_data provided if the platform
	 * needs to do so. If so, config->init_data is completely ignored.
	 */
		if (regulator_desc->of_match)
			dev_warn(dev, "Using provided init data - OF match ignored\n");

		init_data = config->init_data;
		rdev->dev.of_node = of_node_get(config->of_node);

	} else {
		init_data = regulator_of_get_init_data(dev, regulator_desc,
						       config,
	init_data = regulator_of_get_init_data(dev, regulator_desc, config,
					       &rdev->dev.of_node);

	/*
		 * Sometimes not all resources are probed already so we need to
		 * take that into account. This happens most the time if the
		 * ena_gpiod comes from a gpio extender or something else.
	 * Sometimes not all resources are probed already so we need to take
	 * that into account. This happens most the time if the ena_gpiod comes
	 * from a gpio extender or something else.
	 */
	if (PTR_ERR(init_data) == -EPROBE_DEFER) {
		ret = -EPROBE_DEFER;
@@ -5804,13 +5794,16 @@ regulator_register(struct device *dev,
	/*
	 * We need to keep track of any GPIO descriptor coming from the
	 * device tree until we have handled it over to the core. If the
		 * config that was passed in to this function DOES NOT contain a
		 * descriptor, and the config after this call DOES contain a
		 * descriptor, we definitely got one from parsing the device
	 * config that was passed in to this function DOES NOT contain
	 * a descriptor, and the config after this call DOES contain
	 * a descriptor, we definitely got one from parsing the device
	 * tree.
	 */
	if (!cfg->ena_gpiod && config->ena_gpiod)
		dangling_of_gpiod = true;
	if (!init_data) {
		init_data = config->init_data;
		rdev->dev.of_node = of_node_get(config->of_node);
	}

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