Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

regulator: core: Fix regulator supply registration with sysfs

In "regulator: core: Resolve supply name earlier to prevent
double-init", we introduced a bug that prevented the regulator names
from registering properly with sysfs.

Reorder regulator_register such that supply names are properly resolved
and registered.

Fixes: 8a866d527ac0 ("regulator: core: Resolve supply name earlier to prevent double-init")
Link: https://lore.kernel.org/all/58b92e75-f373-dae7-7031-8abd465bb874@samsung.com/
Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20220829165543.24856-1-christian@kohlschutter.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Christian Kohlschütter and committed by
Mark Brown
520fb178 b662748f

+21 -23
+21 -23
drivers/regulator/core.c
··· 5409 5409 bool dangling_of_gpiod = false; 5410 5410 struct device *dev; 5411 5411 int ret, i; 5412 + bool resolved_early = false; 5412 5413 5413 5414 if (cfg == NULL) 5414 5415 return ERR_PTR(-EINVAL); ··· 5513 5512 BLOCKING_INIT_NOTIFIER_HEAD(&rdev->notifier); 5514 5513 INIT_DELAYED_WORK(&rdev->disable_work, regulator_disable_work); 5515 5514 5515 + if (init_data && init_data->supply_regulator) 5516 + rdev->supply_name = init_data->supply_regulator; 5517 + else if (regulator_desc->supply_name) 5518 + rdev->supply_name = regulator_desc->supply_name; 5519 + 5520 + /* register with sysfs */ 5521 + rdev->dev.class = &regulator_class; 5522 + rdev->dev.parent = dev; 5523 + dev_set_name(&rdev->dev, "regulator.%lu", 5524 + (unsigned long) atomic_inc_return(&regulator_no)); 5525 + dev_set_drvdata(&rdev->dev, rdev); 5526 + 5516 5527 /* set regulator constraints */ 5517 5528 if (init_data) 5518 5529 rdev->constraints = kmemdup(&init_data->constraints, ··· 5535 5522 GFP_KERNEL); 5536 5523 if (!rdev->constraints) { 5537 5524 ret = -ENOMEM; 5538 - goto clean; 5525 + goto wash; 5539 5526 } 5540 5527 5541 - if (init_data && init_data->supply_regulator) 5542 - rdev->supply_name = init_data->supply_regulator; 5543 - else if (regulator_desc->supply_name) 5544 - rdev->supply_name = regulator_desc->supply_name; 5545 - 5546 5528 if ((rdev->supply_name && !rdev->supply) && 5547 - (rdev->constraints->always_on || 5548 - rdev->constraints->boot_on)) { 5549 - /* Try to resolve the name of the supplying regulator here first 5550 - * so we prevent double-initializing the regulator, which may 5551 - * cause timing-specific voltage brownouts/glitches that are 5552 - * hard to debug. 5553 - */ 5529 + (rdev->constraints->always_on || 5530 + rdev->constraints->boot_on)) { 5554 5531 ret = regulator_resolve_supply(rdev); 5555 5532 if (ret) 5556 5533 rdev_dbg(rdev, "unable to resolve supply early: %pe\n", 5557 5534 ERR_PTR(ret)); 5535 + 5536 + resolved_early = true; 5558 5537 } 5559 5538 5560 5539 /* perform any regulator specific init */ 5561 5540 if (init_data && init_data->regulator_init) { 5562 5541 ret = init_data->regulator_init(rdev->reg_data); 5563 5542 if (ret < 0) 5564 - goto clean; 5543 + goto wash; 5565 5544 } 5566 5545 5567 5546 if (config->ena_gpiod) { ··· 5561 5556 if (ret != 0) { 5562 5557 rdev_err(rdev, "Failed to request enable GPIO: %pe\n", 5563 5558 ERR_PTR(ret)); 5564 - goto clean; 5559 + goto wash; 5565 5560 } 5566 5561 /* The regulator core took over the GPIO descriptor */ 5567 5562 dangling_cfg_gpiod = false; 5568 5563 dangling_of_gpiod = false; 5569 5564 } 5570 5565 5571 - /* register with sysfs */ 5572 - rdev->dev.class = &regulator_class; 5573 - rdev->dev.parent = dev; 5574 - dev_set_name(&rdev->dev, "regulator.%lu", 5575 - (unsigned long) atomic_inc_return(&regulator_no)); 5576 - dev_set_drvdata(&rdev->dev, rdev); 5577 - 5578 5566 ret = set_machine_constraints(rdev); 5579 - if (ret == -EPROBE_DEFER) { 5567 + if (ret == -EPROBE_DEFER && !resolved_early) { 5580 5568 /* Regulator might be in bypass mode and so needs its supply 5581 5569 * to set the constraints 5582 5570 */