Skip to content

Commit

Permalink
regulator: core: Allow multiple requests of a single supply mapping
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mark Brown committed Jun 26, 2012
1 parent 5aff3a8 commit 222cc7b
Showing 1 changed file with 5 additions and 44 deletions.
49 changes: 5 additions & 44 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,6 @@ static int regulator_check_drms(struct regulator_dev *rdev)
return 0;
}

static ssize_t device_requested_uA_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct regulator *regulator;

regulator = get_device_regulator(dev);
if (regulator == NULL)
return 0;

return sprintf(buf, "%d\n", regulator->uA_load);
}

static ssize_t regulator_uV_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
Expand Down Expand Up @@ -1097,48 +1085,27 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
list_add(&regulator->list, &rdev->consumer_list);

if (dev) {
/* create a 'requested_microamps_name' sysfs entry */
size = scnprintf(buf, REG_STR_SIZE,
"microamps_requested_%s-%s",
dev_name(dev), supply_name);
if (size >= REG_STR_SIZE)
goto overflow_err;

regulator->dev = dev;
sysfs_attr_init(&regulator->dev_attr.attr);
regulator->dev_attr.attr.name = kstrdup(buf, GFP_KERNEL);
if (regulator->dev_attr.attr.name == NULL)
goto attr_name_err;

regulator->dev_attr.attr.mode = 0444;
regulator->dev_attr.show = device_requested_uA_show;
err = device_create_file(dev, &regulator->dev_attr);
if (err < 0) {
rdev_warn(rdev, "could not add regulator_dev requested microamps sysfs entry\n");
goto attr_name_err;
}

/* also add a link to the device sysfs entry */
/* Add a link to the device sysfs entry */
size = scnprintf(buf, REG_STR_SIZE, "%s-%s",
dev->kobj.name, supply_name);
if (size >= REG_STR_SIZE)
goto attr_err;
goto overflow_err;

regulator->supply_name = kstrdup(buf, GFP_KERNEL);
if (regulator->supply_name == NULL)
goto attr_err;
goto overflow_err;

err = sysfs_create_link(&rdev->dev.kobj, &dev->kobj,
buf);
if (err) {
rdev_warn(rdev, "could not add device link %s err %d\n",
dev->kobj.name, err);
goto link_name_err;
/* non-fatal */
}
} else {
regulator->supply_name = kstrdup(supply_name, GFP_KERNEL);
if (regulator->supply_name == NULL)
goto attr_err;
goto overflow_err;
}

regulator->debugfs = debugfs_create_dir(regulator->supply_name,
Expand All @@ -1165,12 +1132,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,

mutex_unlock(&rdev->mutex);
return regulator;
link_name_err:
kfree(regulator->supply_name);
attr_err:
device_remove_file(regulator->dev, &regulator->dev_attr);
attr_name_err:
kfree(regulator->dev_attr.attr.name);
overflow_err:
list_del(&regulator->list);
kfree(regulator);
Expand Down

0 comments on commit 222cc7b

Please sign in to comment.