diff options
| -rw-r--r-- | drivers/regulator/core.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index cc3dfd66f395..f59821f10fdc 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -81,6 +81,9 @@ struct regulator { | |||
| 81 | char *supply_name; | 81 | char *supply_name; |
| 82 | struct device_attribute dev_attr; | 82 | struct device_attribute dev_attr; |
| 83 | struct regulator_dev *rdev; | 83 | struct regulator_dev *rdev; |
| 84 | #ifdef CONFIG_DEBUG_FS | ||
| 85 | struct dentry *debugfs; | ||
| 86 | #endif | ||
| 84 | }; | 87 | }; |
| 85 | 88 | ||
| 86 | static int _regulator_is_enabled(struct regulator_dev *rdev); | 89 | static int _regulator_is_enabled(struct regulator_dev *rdev); |
| @@ -1093,7 +1096,28 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, | |||
| 1093 | dev->kobj.name, err); | 1096 | dev->kobj.name, err); |
| 1094 | goto link_name_err; | 1097 | goto link_name_err; |
| 1095 | } | 1098 | } |
| 1099 | } else { | ||
| 1100 | regulator->supply_name = kstrdup(supply_name, GFP_KERNEL); | ||
| 1101 | if (regulator->supply_name == NULL) | ||
| 1102 | goto attr_err; | ||
| 1103 | } | ||
| 1104 | |||
| 1105 | #ifdef CONFIG_DEBUG_FS | ||
| 1106 | regulator->debugfs = debugfs_create_dir(regulator->supply_name, | ||
| 1107 | rdev->debugfs); | ||
| 1108 | if (IS_ERR_OR_NULL(regulator->debugfs)) { | ||
| 1109 | rdev_warn(rdev, "Failed to create debugfs directory\n"); | ||
| 1110 | regulator->debugfs = NULL; | ||
| 1111 | } else { | ||
| 1112 | debugfs_create_u32("uA_load", 0444, regulator->debugfs, | ||
| 1113 | ®ulator->uA_load); | ||
| 1114 | debugfs_create_u32("min_uV", 0444, regulator->debugfs, | ||
| 1115 | ®ulator->min_uV); | ||
| 1116 | debugfs_create_u32("max_uV", 0444, regulator->debugfs, | ||
| 1117 | ®ulator->max_uV); | ||
| 1096 | } | 1118 | } |
| 1119 | #endif | ||
| 1120 | |||
| 1097 | mutex_unlock(&rdev->mutex); | 1121 | mutex_unlock(&rdev->mutex); |
| 1098 | return regulator; | 1122 | return regulator; |
| 1099 | link_name_err: | 1123 | link_name_err: |
| @@ -1272,13 +1296,17 @@ void regulator_put(struct regulator *regulator) | |||
| 1272 | mutex_lock(®ulator_list_mutex); | 1296 | mutex_lock(®ulator_list_mutex); |
| 1273 | rdev = regulator->rdev; | 1297 | rdev = regulator->rdev; |
| 1274 | 1298 | ||
| 1299 | #ifdef CONFIG_DEBUG_FS | ||
| 1300 | debugfs_remove_recursive(regulator->debugfs); | ||
| 1301 | #endif | ||
| 1302 | |||
| 1275 | /* remove any sysfs entries */ | 1303 | /* remove any sysfs entries */ |
| 1276 | if (regulator->dev) { | 1304 | if (regulator->dev) { |
| 1277 | sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); | 1305 | sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); |
| 1278 | kfree(regulator->supply_name); | ||
| 1279 | device_remove_file(regulator->dev, ®ulator->dev_attr); | 1306 | device_remove_file(regulator->dev, ®ulator->dev_attr); |
| 1280 | kfree(regulator->dev_attr.attr.name); | 1307 | kfree(regulator->dev_attr.attr.name); |
| 1281 | } | 1308 | } |
| 1309 | kfree(regulator->supply_name); | ||
| 1282 | list_del(®ulator->list); | 1310 | list_del(®ulator->list); |
| 1283 | kfree(regulator); | 1311 | kfree(regulator); |
| 1284 | 1312 | ||
