diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index b899947d839d87b03608d1f9bf4b4208cf57aa01..cc242aa368efd0bad3159b799a65cc8de7b281f6 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3502,7 +3502,18 @@ static struct class regulator_class = { static void rdev_init_debugfs(struct regulator_dev *rdev) { - rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root); + struct device *parent = rdev->dev.parent; + const char *rname = rdev_get_name(rdev); + char name[NAME_MAX]; + + /* Avoid duplicate debugfs directory names */ + if (parent && rname == rdev->desc->name) { + snprintf(name, sizeof(name), "%s-%s", dev_name(parent), + rname); + rname = name; + } + + rdev->debugfs = debugfs_create_dir(rname, debugfs_root); if (!rdev->debugfs) { rdev_warn(rdev, "Failed to create debugfs directory\n"); return;