Skip to content

Commit 2a4b49b

Browse files
jhovoldbroonie
authored andcommitted
regulator: core: fix debugfs creation regression
regulator_get() may sometimes be called more than once for the same consumer device, something which before commit dbe954d ("regulator: core: Avoid debugfs: Directory ... already present! error") resulted in errors being logged. A couple of recent commits broke the handling of such cases so that attributes are now erroneously created in the debugfs root directory the second time a regulator is requested and the log is filled with errors like: debugfs: File 'uA_load' in directory '/' already present! debugfs: File 'min_uV' in directory '/' already present! debugfs: File 'max_uV' in directory '/' already present! debugfs: File 'constraint_flags' in directory '/' already present! on any further calls. Fixes: 2715bb1 ("regulator: core: Fix more error checking for debugfs_create_dir()") Fixes: 0888071 ("regulator: core: Streamline debugfs operations") Cc: stable@vger.kernel.org Cc: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Link: https://lore.kernel.org/r/20240509133304.8883-1-johan+linaro@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d1ef160 commit 2a4b49b

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

drivers/regulator/core.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,19 +1911,24 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
19111911
}
19121912
}
19131913

1914-
if (err != -EEXIST)
1914+
if (err != -EEXIST) {
19151915
regulator->debugfs = debugfs_create_dir(supply_name, rdev->debugfs);
1916-
if (IS_ERR(regulator->debugfs))
1917-
rdev_dbg(rdev, "Failed to create debugfs directory\n");
1916+
if (IS_ERR(regulator->debugfs)) {
1917+
rdev_dbg(rdev, "Failed to create debugfs directory\n");
1918+
regulator->debugfs = NULL;
1919+
}
1920+
}
19181921

1919-
debugfs_create_u32("uA_load", 0444, regulator->debugfs,
1920-
&regulator->uA_load);
1921-
debugfs_create_u32("min_uV", 0444, regulator->debugfs,
1922-
&regulator->voltage[PM_SUSPEND_ON].min_uV);
1923-
debugfs_create_u32("max_uV", 0444, regulator->debugfs,
1924-
&regulator->voltage[PM_SUSPEND_ON].max_uV);
1925-
debugfs_create_file("constraint_flags", 0444, regulator->debugfs,
1926-
regulator, &constraint_flags_fops);
1922+
if (regulator->debugfs) {
1923+
debugfs_create_u32("uA_load", 0444, regulator->debugfs,
1924+
&regulator->uA_load);
1925+
debugfs_create_u32("min_uV", 0444, regulator->debugfs,
1926+
&regulator->voltage[PM_SUSPEND_ON].min_uV);
1927+
debugfs_create_u32("max_uV", 0444, regulator->debugfs,
1928+
&regulator->voltage[PM_SUSPEND_ON].max_uV);
1929+
debugfs_create_file("constraint_flags", 0444, regulator->debugfs,
1930+
regulator, &constraint_flags_fops);
1931+
}
19271932

19281933
/*
19291934
* Check now if the regulator is an always on regulator - if

0 commit comments

Comments
 (0)