aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-22 06:39:16 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-26 06:53:47 -0400
commit222cc7b1cefbab1287ed5d5e3cce1f45aec60d39 (patch)
tree012b9974ef73d1547e67adb9a225c495847f49f3 /drivers/regulator/core.c
parent5aff3a8b20c54888e199e863744848007f1f4120 (diff)
regulator: core: Allow multiple requests of a single supply mapping
Sometimes it may be useful to allow a device to request a supply multiple times, for example in order to allow framework management of some uses of the supply with some additional driver specific management or in order to allow multiple children of an MFD to work with the supply. Currently this is not possible due to the creation of Solve this by removing the requested_uA entry (we have no current users of this feature anyway) and ignoring errors creating the symlink to the consumer. We should do something nicer than this as this causes sysfs to spew enormous warnings but it allows users to run for now. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c49
1 files changed, 5 insertions, 44 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 890fa5eb770d..00c787c01f3b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -303,18 +303,6 @@ static int regulator_check_drms(struct regulator_dev *rdev)
303 return 0; 303 return 0;
304} 304}
305 305
306static ssize_t device_requested_uA_show(struct device *dev,
307 struct device_attribute *attr, char *buf)
308{
309 struct regulator *regulator;
310
311 regulator = get_device_regulator(dev);
312 if (regulator == NULL)
313 return 0;
314
315 return sprintf(buf, "%d\n", regulator->uA_load);
316}
317
318static ssize_t regulator_uV_show(struct device *dev, 306static ssize_t regulator_uV_show(struct device *dev,
319 struct device_attribute *attr, char *buf) 307 struct device_attribute *attr, char *buf)
320{ 308{
@@ -1097,48 +1085,27 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1097 list_add(&regulator->list, &rdev->consumer_list); 1085 list_add(&regulator->list, &rdev->consumer_list);
1098 1086
1099 if (dev) { 1087 if (dev) {
1100 /* create a 'requested_microamps_name' sysfs entry */ 1088 /* Add a link to the device sysfs entry */
1101 size = scnprintf(buf, REG_STR_SIZE,
1102 "microamps_requested_%s-%s",
1103 dev_name(dev), supply_name);
1104 if (size >= REG_STR_SIZE)
1105 goto overflow_err;
1106
1107 regulator->dev = dev;
1108 sysfs_attr_init(&regulator->dev_attr.attr);
1109 regulator->dev_attr.attr.name = kstrdup(buf, GFP_KERNEL);
1110 if (regulator->dev_attr.attr.name == NULL)
1111 goto attr_name_err;
1112
1113 regulator->dev_attr.attr.mode = 0444;
1114 regulator->dev_attr.show = device_requested_uA_show;
1115 err = device_create_file(dev, &regulator->dev_attr);
1116 if (err < 0) {
1117 rdev_warn(rdev, "could not add regulator_dev requested microamps sysfs entry\n");
1118 goto attr_name_err;
1119 }
1120
1121 /* also add a link to the device sysfs entry */
1122 size = scnprintf(buf, REG_STR_SIZE, "%s-%s", 1089 size = scnprintf(buf, REG_STR_SIZE, "%s-%s",
1123 dev->kobj.name, supply_name); 1090 dev->kobj.name, supply_name);
1124 if (size >= REG_STR_SIZE) 1091 if (size >= REG_STR_SIZE)
1125 goto attr_err; 1092 goto overflow_err;
1126 1093
1127 regulator->supply_name = kstrdup(buf, GFP_KERNEL); 1094 regulator->supply_name = kstrdup(buf, GFP_KERNEL);
1128 if (regulator->supply_name == NULL) 1095 if (regulator->supply_name == NULL)
1129 goto attr_err; 1096 goto overflow_err;
1130 1097
1131 err = sysfs_create_link(&rdev->dev.kobj, &dev->kobj, 1098 err = sysfs_create_link(&rdev->dev.kobj, &dev->kobj,
1132 buf); 1099 buf);
1133 if (err) { 1100 if (err) {
1134 rdev_warn(rdev, "could not add device link %s err %d\n", 1101 rdev_warn(rdev, "could not add device link %s err %d\n",
1135 dev->kobj.name, err); 1102 dev->kobj.name, err);
1136 goto link_name_err; 1103 /* non-fatal */
1137 } 1104 }
1138 } else { 1105 } else {
1139 regulator->supply_name = kstrdup(supply_name, GFP_KERNEL); 1106 regulator->supply_name = kstrdup(supply_name, GFP_KERNEL);
1140 if (regulator->supply_name == NULL) 1107 if (regulator->supply_name == NULL)
1141 goto attr_err; 1108 goto overflow_err;
1142 } 1109 }
1143 1110
1144 regulator->debugfs = debugfs_create_dir(regulator->supply_name, 1111 regulator->debugfs = debugfs_create_dir(regulator->supply_name,
@@ -1165,12 +1132,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1165 1132
1166 mutex_unlock(&rdev->mutex); 1133 mutex_unlock(&rdev->mutex);
1167 return regulator; 1134 return regulator;
1168link_name_err:
1169 kfree(regulator->supply_name);
1170attr_err:
1171 device_remove_file(regulator->dev, &regulator->dev_attr);
1172attr_name_err:
1173 kfree(regulator->dev_attr.attr.name);
1174overflow_err: 1135overflow_err:
1175 list_del(&regulator->list); 1136 list_del(&regulator->list);
1176 kfree(regulator); 1137 kfree(regulator);