aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2014-10-17 11:17:03 -0400
committerMark Brown <broonie@kernel.org>2015-03-27 19:14:18 -0400
commita9eaa8130707d4013fb109b80323489c0d0111ac (patch)
tree8854c4c7a3c10df8ee0731ceeb0db7328f575c30 /drivers/regulator/core.c
parentc517d838eb7d07bbe9507871fab3931deccff539 (diff)
regulator: Ensure unique regulator debugfs directory names
If multiple regulator devices of the same type exist in a system, the regulator driver assigns generic names for the regulators it provides, and debugfs is enabled, the regulator subsystem attempts to create multiple entries with the same name in the regulator debugfs directory. This fails for all but the first regulator, resulting in multiple "Failed to create debugfs directory" log entries. To avoid the problem, prepend the debugfs directory name for a regulator with its parent device name if available, but only if no explicit regulator name was provided. Cc: Alan Tull <atull@opensource.altera.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b899947d839d..cc242aa368ef 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3502,7 +3502,18 @@ static struct class regulator_class = {
3502 3502
3503static void rdev_init_debugfs(struct regulator_dev *rdev) 3503static void rdev_init_debugfs(struct regulator_dev *rdev)
3504{ 3504{
3505 rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root); 3505 struct device *parent = rdev->dev.parent;
3506 const char *rname = rdev_get_name(rdev);
3507 char name[NAME_MAX];
3508
3509 /* Avoid duplicate debugfs directory names */
3510 if (parent && rname == rdev->desc->name) {
3511 snprintf(name, sizeof(name), "%s-%s", dev_name(parent),
3512 rname);
3513 rname = name;
3514 }
3515
3516 rdev->debugfs = debugfs_create_dir(rname, debugfs_root);
3506 if (!rdev->debugfs) { 3517 if (!rdev->debugfs) {
3507 rdev_warn(rdev, "Failed to create debugfs directory\n"); 3518 rdev_warn(rdev, "Failed to create debugfs directory\n");
3508 return; 3519 return;