summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2017-07-03 16:52:16 +0100
committerMark Brown <broonie@kernel.org>2017-07-03 16:52:16 +0100
commitfcaa3167b2763d35a7dc60c5724f23e441d29f4f (patch)
treec3a747d7c71b3e79440091e4c068e9c3da5e965f /drivers/regulator
parent85fd19e432b5ed5357d54f1048a088d9eb5aae94 (diff)
parentdbc559554086f176b04f97eec561ad26ee54e47c (diff)
Merge remote-tracking branch 'regulator/topic/core' into regulator-next
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9fecbd4e3546..e9f74331fc69 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1462,7 +1462,7 @@ static struct regulator_dev *regulator_lookup_by_name(const char *name)
static struct regulator_dev *regulator_dev_lookup(struct device *dev,
const char *supply)
{
- struct regulator_dev *r;
+ struct regulator_dev *r = NULL;
struct device_node *node;
struct regulator_map *map;
const char *devname = NULL;
@@ -1489,10 +1489,6 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
if (dev)
devname = dev_name(dev);
- r = regulator_lookup_by_name(supply);
- if (r)
- return r;
-
mutex_lock(&regulator_list_mutex);
list_for_each_entry(map, &regulator_map_list, list) {
/* If the mapping has a device set up it must match */
@@ -1511,6 +1507,10 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
if (r)
return r;
+ r = regulator_lookup_by_name(supply);
+ if (r)
+ return r;
+
return ERR_PTR(-ENODEV);
}
@@ -4312,41 +4312,31 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
EXPORT_SYMBOL_GPL(regulator_get_init_drvdata);
#ifdef CONFIG_DEBUG_FS
-static ssize_t supply_map_read_file(struct file *file, char __user *user_buf,
- size_t count, loff_t *ppos)
+static int supply_map_show(struct seq_file *sf, void *data)
{
- char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- ssize_t len, ret = 0;
struct regulator_map *map;
- if (!buf)
- return -ENOMEM;
-
list_for_each_entry(map, &regulator_map_list, list) {
- len = snprintf(buf + ret, PAGE_SIZE - ret,
- "%s -> %s.%s\n",
- rdev_get_name(map->regulator), map->dev_name,
- map->supply);
- if (len >= 0)
- ret += len;
- if (ret > PAGE_SIZE) {
- ret = PAGE_SIZE;
- break;
- }
+ seq_printf(sf, "%s -> %s.%s\n",
+ rdev_get_name(map->regulator), map->dev_name,
+ map->supply);
}
- ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
-
- kfree(buf);
+ return 0;
+}
- return ret;
+static int supply_map_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, supply_map_show, inode->i_private);
}
#endif
static const struct file_operations supply_map_fops = {
#ifdef CONFIG_DEBUG_FS
- .read = supply_map_read_file,
- .llseek = default_llseek,
+ .open = supply_map_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
#endif
};