Skip to content

Commit 21d1ccf

Browse files
committed
Merge tag 'regulator-fix-v6.14-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "More fixes than I'd like at this point, some of which is due to me cooking things in -next for a bit and resetting that cooking time as more fixes came in. - Christian Eggers fixed some race conditions with the dummy regulator not being available very early in boot due to the use of asynchronous probing, both the provider side (ensuring that it's availalbe) and consumer side (handling things if that goes wrong) are fixed - Ludvig Pärsson fixed some lockdep issues with the debugfs registration for regulators holding more locks than it really needs causing issues later when looking at the resulting debugfs.boot - Some device specific fixes for incorrect descriptions of the RTQ2208 from ChiYuan Huang" * tag 'regulator-fix-v6.14-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: rtq2208: Fix the LDO DVS capability regulator: rtq2208: Fix incorrect buck converter phase mapping regulator: check that dummy regulator has been probed before using it regulator: dummy: force synchronous probing regulator: core: Fix deadlock in create_regulator()
2 parents 3e49db0 + b65439d commit 21d1ccf

File tree

3 files changed

+178
-128
lines changed

3 files changed

+178
-128
lines changed

drivers/regulator/core.c

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,12 +1830,49 @@ static const struct file_operations constraint_flags_fops = {
18301830

18311831
#define REG_STR_SIZE 64
18321832

1833+
static void link_and_create_debugfs(struct regulator *regulator, struct regulator_dev *rdev,
1834+
struct device *dev)
1835+
{
1836+
int err = 0;
1837+
1838+
if (dev) {
1839+
regulator->dev = dev;
1840+
1841+
/* Add a link to the device sysfs entry */
1842+
err = sysfs_create_link_nowarn(&rdev->dev.kobj, &dev->kobj,
1843+
regulator->supply_name);
1844+
if (err) {
1845+
rdev_dbg(rdev, "could not add device link %s: %pe\n",
1846+
dev->kobj.name, ERR_PTR(err));
1847+
/* non-fatal */
1848+
}
1849+
}
1850+
1851+
if (err != -EEXIST) {
1852+
regulator->debugfs = debugfs_create_dir(regulator->supply_name, rdev->debugfs);
1853+
if (IS_ERR(regulator->debugfs)) {
1854+
rdev_dbg(rdev, "Failed to create debugfs directory\n");
1855+
regulator->debugfs = NULL;
1856+
}
1857+
}
1858+
1859+
if (regulator->debugfs) {
1860+
debugfs_create_u32("uA_load", 0444, regulator->debugfs,
1861+
&regulator->uA_load);
1862+
debugfs_create_u32("min_uV", 0444, regulator->debugfs,
1863+
&regulator->voltage[PM_SUSPEND_ON].min_uV);
1864+
debugfs_create_u32("max_uV", 0444, regulator->debugfs,
1865+
&regulator->voltage[PM_SUSPEND_ON].max_uV);
1866+
debugfs_create_file("constraint_flags", 0444, regulator->debugfs,
1867+
regulator, &constraint_flags_fops);
1868+
}
1869+
}
1870+
18331871
static struct regulator *create_regulator(struct regulator_dev *rdev,
18341872
struct device *dev,
18351873
const char *supply_name)
18361874
{
18371875
struct regulator *regulator;
1838-
int err = 0;
18391876

18401877
lockdep_assert_held_once(&rdev->mutex.base);
18411878

@@ -1868,38 +1905,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
18681905

18691906
list_add(&regulator->list, &rdev->consumer_list);
18701907

1871-
if (dev) {
1872-
regulator->dev = dev;
1873-
1874-
/* Add a link to the device sysfs entry */
1875-
err = sysfs_create_link_nowarn(&rdev->dev.kobj, &dev->kobj,
1876-
supply_name);
1877-
if (err) {
1878-
rdev_dbg(rdev, "could not add device link %s: %pe\n",
1879-
dev->kobj.name, ERR_PTR(err));
1880-
/* non-fatal */
1881-
}
1882-
}
1883-
1884-
if (err != -EEXIST) {
1885-
regulator->debugfs = debugfs_create_dir(supply_name, rdev->debugfs);
1886-
if (IS_ERR(regulator->debugfs)) {
1887-
rdev_dbg(rdev, "Failed to create debugfs directory\n");
1888-
regulator->debugfs = NULL;
1889-
}
1890-
}
1891-
1892-
if (regulator->debugfs) {
1893-
debugfs_create_u32("uA_load", 0444, regulator->debugfs,
1894-
&regulator->uA_load);
1895-
debugfs_create_u32("min_uV", 0444, regulator->debugfs,
1896-
&regulator->voltage[PM_SUSPEND_ON].min_uV);
1897-
debugfs_create_u32("max_uV", 0444, regulator->debugfs,
1898-
&regulator->voltage[PM_SUSPEND_ON].max_uV);
1899-
debugfs_create_file("constraint_flags", 0444, regulator->debugfs,
1900-
regulator, &constraint_flags_fops);
1901-
}
1902-
19031908
/*
19041909
* Check now if the regulator is an always on regulator - if
19051910
* it is then we don't need to do nearly so much work for
@@ -2069,6 +2074,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
20692074

20702075
if (have_full_constraints()) {
20712076
r = dummy_regulator_rdev;
2077+
if (!r) {
2078+
ret = -EPROBE_DEFER;
2079+
goto out;
2080+
}
20722081
get_device(&r->dev);
20732082
} else {
20742083
dev_err(dev, "Failed to resolve %s-supply for %s\n",
@@ -2086,6 +2095,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
20862095
goto out;
20872096
}
20882097
r = dummy_regulator_rdev;
2098+
if (!r) {
2099+
ret = -EPROBE_DEFER;
2100+
goto out;
2101+
}
20892102
get_device(&r->dev);
20902103
}
20912104

@@ -2133,6 +2146,9 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
21332146

21342147
regulator_unlock_two(rdev, r, &ww_ctx);
21352148

2149+
/* rdev->supply was created in set_supply() */
2150+
link_and_create_debugfs(rdev->supply, r, &rdev->dev);
2151+
21362152
/*
21372153
* In set_machine_constraints() we may have turned this regulator on
21382154
* but we couldn't propagate to the supply if it hadn't been resolved
@@ -2211,8 +2227,10 @@ struct regulator *_regulator_get_common(struct regulator_dev *rdev, struct devic
22112227
* enabled, even if it isn't hooked up, and just
22122228
* provide a dummy.
22132229
*/
2214-
dev_warn(dev, "supply %s not found, using dummy regulator\n", id);
22152230
rdev = dummy_regulator_rdev;
2231+
if (!rdev)
2232+
return ERR_PTR(-EPROBE_DEFER);
2233+
dev_warn(dev, "supply %s not found, using dummy regulator\n", id);
22162234
get_device(&rdev->dev);
22172235
break;
22182236

@@ -2271,6 +2289,8 @@ struct regulator *_regulator_get_common(struct regulator_dev *rdev, struct devic
22712289
return regulator;
22722290
}
22732291

2292+
link_and_create_debugfs(regulator, rdev, dev);
2293+
22742294
rdev->open_count++;
22752295
if (get_type == EXCLUSIVE_GET) {
22762296
rdev->exclusive = 1;

drivers/regulator/dummy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static struct platform_driver dummy_regulator_driver = {
6060
.probe = dummy_regulator_probe,
6161
.driver = {
6262
.name = "reg-dummy",
63-
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
63+
.probe_type = PROBE_FORCE_SYNCHRONOUS,
6464
},
6565
};
6666

0 commit comments

Comments
 (0)