Skip to content

Commit 0888071

Browse files
geertubroonie
authored andcommitted
regulator: core: Streamline debugfs operations
If CONFIG_DEBUG_FS is not set: regulator: Failed to create debugfs directory ... regulator-dummy: Failed to create debugfs directory As per the comments for debugfs_create_dir(), errors returned by this function should be expected, and ignored: * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned. * * NOTE: it's expected that most callers should _ignore_ the errors returned * by this function. Other debugfs functions handle the fact that the "dentry" * passed to them could be an error and they don't crash in that case. * Drivers should generally work fine even if debugfs fails to init anyway. Adhere to the debugfs spirit, and streamline all operations by: 1. Demoting the importance of the printed error messages to debug level, like is already done in create_regulator(), 2. Further ignoring any returned errors, as by design, all debugfs functions are no-ops when passed an error pointer. Fixes: 2bf1c45 ("regulator: Fix error checking for debugfs_create_dir") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/2f8bb6e113359ddfab7b59e4d4274bd4c06d6d0a.1685013051.git.geert+renesas@glider.be Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 2715bb1 commit 0888071

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

drivers/regulator/core.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,19 +1911,17 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
19111911

19121912
if (err != -EEXIST)
19131913
regulator->debugfs = debugfs_create_dir(supply_name, rdev->debugfs);
1914-
if (IS_ERR(regulator->debugfs)) {
1914+
if (IS_ERR(regulator->debugfs))
19151915
rdev_dbg(rdev, "Failed to create debugfs directory\n");
1916-
} else {
1917-
debugfs_create_u32("uA_load", 0444, regulator->debugfs,
1918-
&regulator->uA_load);
1919-
debugfs_create_u32("min_uV", 0444, regulator->debugfs,
1920-
&regulator->voltage[PM_SUSPEND_ON].min_uV);
1921-
debugfs_create_u32("max_uV", 0444, regulator->debugfs,
1922-
&regulator->voltage[PM_SUSPEND_ON].max_uV);
1923-
debugfs_create_file("constraint_flags", 0444,
1924-
regulator->debugfs, regulator,
1925-
&constraint_flags_fops);
1926-
}
1916+
1917+
debugfs_create_u32("uA_load", 0444, regulator->debugfs,
1918+
&regulator->uA_load);
1919+
debugfs_create_u32("min_uV", 0444, regulator->debugfs,
1920+
&regulator->voltage[PM_SUSPEND_ON].min_uV);
1921+
debugfs_create_u32("max_uV", 0444, regulator->debugfs,
1922+
&regulator->voltage[PM_SUSPEND_ON].max_uV);
1923+
debugfs_create_file("constraint_flags", 0444, regulator->debugfs,
1924+
regulator, &constraint_flags_fops);
19271925

19281926
/*
19291927
* Check now if the regulator is an always on regulator - if
@@ -5256,10 +5254,8 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
52565254
}
52575255

52585256
rdev->debugfs = debugfs_create_dir(rname, debugfs_root);
5259-
if (IS_ERR(rdev->debugfs)) {
5260-
rdev_warn(rdev, "Failed to create debugfs directory\n");
5261-
return;
5262-
}
5257+
if (IS_ERR(rdev->debugfs))
5258+
rdev_dbg(rdev, "Failed to create debugfs directory\n");
52635259

52645260
debugfs_create_u32("use_count", 0444, rdev->debugfs,
52655261
&rdev->use_count);
@@ -6179,7 +6175,7 @@ static int __init regulator_init(void)
61796175

61806176
debugfs_root = debugfs_create_dir("regulator", NULL);
61816177
if (IS_ERR(debugfs_root))
6182-
pr_warn("regulator: Failed to create debugfs directory\n");
6178+
pr_debug("regulator: Failed to create debugfs directory\n");
61836179

61846180
#ifdef CONFIG_DEBUG_FS
61856181
debugfs_create_file("supply_map", 0444, debugfs_root, NULL,

0 commit comments

Comments
 (0)