mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-05 19:31:57 -04:00
regulator: gpio: Add input_supply support in gpio_regulator_config
[ Upstream commit adfdfcbdbd32b356323a3db6d3a683270051a7e6 ] This is simillar as fixed-regulator. Used to extract regulator parent from the device tree. Without that property used, the parent regulator can be shut down (if not an always on). Thus leading to inappropriate behavior: On am62-SP-SK this fix is required to avoid tps65219 ldo1 (SDMMC rail) to be shut down after boot completion. Signed-off-by: Jerome Neanne <jneanne@baylibre.com> Link: https://lore.kernel.org/r/20220929132526.29427-2-jneanne@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org> Stable-dep-of: c9764fd88bc7 ("regulator: gpio: Fix the out-of-bounds access to drvdata::gpiods") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
b49d224d18
commit
285e4fb525
2 changed files with 17 additions and 0 deletions
|
|
@ -213,6 +213,9 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
|
|||
regtype);
|
||||
}
|
||||
|
||||
if (of_find_property(np, "vin-supply", NULL))
|
||||
config->input_supply = "vin";
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
|
@ -252,6 +255,18 @@ static int gpio_regulator_probe(struct platform_device *pdev)
|
|||
|
||||
drvdata->gpiods = devm_kzalloc(dev, sizeof(struct gpio_desc *),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (config->input_supply) {
|
||||
drvdata->desc.supply_name = devm_kstrdup(&pdev->dev,
|
||||
config->input_supply,
|
||||
GFP_KERNEL);
|
||||
if (!drvdata->desc.supply_name) {
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to allocate input supply\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
if (!drvdata->gpiods)
|
||||
return -ENOMEM;
|
||||
for (i = 0; i < config->ngpios; i++) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ struct gpio_regulator_state {
|
|||
/**
|
||||
* struct gpio_regulator_config - config structure
|
||||
* @supply_name: Name of the regulator supply
|
||||
* @input_supply: Name of the input regulator supply
|
||||
* @enabled_at_boot: Whether regulator has been enabled at
|
||||
* boot or not. 1 = Yes, 0 = No
|
||||
* This is used to keep the regulator at
|
||||
|
|
@ -62,6 +63,7 @@ struct gpio_regulator_state {
|
|||
*/
|
||||
struct gpio_regulator_config {
|
||||
const char *supply_name;
|
||||
const char *input_supply;
|
||||
|
||||
unsigned enabled_at_boot:1;
|
||||
unsigned startup_delay;
|
||||
|
|
|
|||
Loading…
Reference in a new issue