Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: Add basic per consumer debugfs

Report the requested load and voltage for each consumer in debugfs when it
is enabled.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>

authored by

Mark Brown and committed by
Liam Girdwood
5de70519 7d51a0db

+29 -1
+29 -1
drivers/regulator/core.c
··· 81 81 char *supply_name; 82 82 struct device_attribute dev_attr; 83 83 struct regulator_dev *rdev; 84 + #ifdef CONFIG_DEBUG_FS 85 + struct dentry *debugfs; 86 + #endif 84 87 }; 85 88 86 89 static int _regulator_is_enabled(struct regulator_dev *rdev); ··· 1096 1093 dev->kobj.name, err); 1097 1094 goto link_name_err; 1098 1095 } 1096 + } else { 1097 + regulator->supply_name = kstrdup(supply_name, GFP_KERNEL); 1098 + if (regulator->supply_name == NULL) 1099 + goto attr_err; 1099 1100 } 1101 + 1102 + #ifdef CONFIG_DEBUG_FS 1103 + regulator->debugfs = debugfs_create_dir(regulator->supply_name, 1104 + rdev->debugfs); 1105 + if (IS_ERR_OR_NULL(regulator->debugfs)) { 1106 + rdev_warn(rdev, "Failed to create debugfs directory\n"); 1107 + regulator->debugfs = NULL; 1108 + } else { 1109 + debugfs_create_u32("uA_load", 0444, regulator->debugfs, 1110 + &regulator->uA_load); 1111 + debugfs_create_u32("min_uV", 0444, regulator->debugfs, 1112 + &regulator->min_uV); 1113 + debugfs_create_u32("max_uV", 0444, regulator->debugfs, 1114 + &regulator->max_uV); 1115 + } 1116 + #endif 1117 + 1100 1118 mutex_unlock(&rdev->mutex); 1101 1119 return regulator; 1102 1120 link_name_err: ··· 1296 1272 mutex_lock(&regulator_list_mutex); 1297 1273 rdev = regulator->rdev; 1298 1274 1275 + #ifdef CONFIG_DEBUG_FS 1276 + debugfs_remove_recursive(regulator->debugfs); 1277 + #endif 1278 + 1299 1279 /* remove any sysfs entries */ 1300 1280 if (regulator->dev) { 1301 1281 sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); 1302 - kfree(regulator->supply_name); 1303 1282 device_remove_file(regulator->dev, &regulator->dev_attr); 1304 1283 kfree(regulator->dev_attr.attr.name); 1305 1284 } 1285 + kfree(regulator->supply_name); 1306 1286 list_del(&regulator->list); 1307 1287 kfree(regulator); 1308 1288