Skip to content

Commit fcaa316

Browse files
committed
Merge remote-tracking branch 'regulator/topic/core' into regulator-next
2 parents 85fd19e + dbc5595 commit fcaa316

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

drivers/regulator/core.c

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ static struct regulator_dev *regulator_lookup_by_name(const char *name)
14621462
static struct regulator_dev *regulator_dev_lookup(struct device *dev,
14631463
const char *supply)
14641464
{
1465-
struct regulator_dev *r;
1465+
struct regulator_dev *r = NULL;
14661466
struct device_node *node;
14671467
struct regulator_map *map;
14681468
const char *devname = NULL;
@@ -1489,10 +1489,6 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
14891489
if (dev)
14901490
devname = dev_name(dev);
14911491

1492-
r = regulator_lookup_by_name(supply);
1493-
if (r)
1494-
return r;
1495-
14961492
mutex_lock(&regulator_list_mutex);
14971493
list_for_each_entry(map, &regulator_map_list, list) {
14981494
/* If the mapping has a device set up it must match */
@@ -1508,6 +1504,10 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
15081504
}
15091505
mutex_unlock(&regulator_list_mutex);
15101506

1507+
if (r)
1508+
return r;
1509+
1510+
r = regulator_lookup_by_name(supply);
15111511
if (r)
15121512
return r;
15131513

@@ -4312,41 +4312,31 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
43124312
EXPORT_SYMBOL_GPL(regulator_get_init_drvdata);
43134313

43144314
#ifdef CONFIG_DEBUG_FS
4315-
static ssize_t supply_map_read_file(struct file *file, char __user *user_buf,
4316-
size_t count, loff_t *ppos)
4315+
static int supply_map_show(struct seq_file *sf, void *data)
43174316
{
4318-
char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
4319-
ssize_t len, ret = 0;
43204317
struct regulator_map *map;
43214318

4322-
if (!buf)
4323-
return -ENOMEM;
4324-
43254319
list_for_each_entry(map, &regulator_map_list, list) {
4326-
len = snprintf(buf + ret, PAGE_SIZE - ret,
4327-
"%s -> %s.%s\n",
4328-
rdev_get_name(map->regulator), map->dev_name,
4329-
map->supply);
4330-
if (len >= 0)
4331-
ret += len;
4332-
if (ret > PAGE_SIZE) {
4333-
ret = PAGE_SIZE;
4334-
break;
4335-
}
4320+
seq_printf(sf, "%s -> %s.%s\n",
4321+
rdev_get_name(map->regulator), map->dev_name,
4322+
map->supply);
43364323
}
43374324

4338-
ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
4339-
4340-
kfree(buf);
4325+
return 0;
4326+
}
43414327

4342-
return ret;
4328+
static int supply_map_open(struct inode *inode, struct file *file)
4329+
{
4330+
return single_open(file, supply_map_show, inode->i_private);
43434331
}
43444332
#endif
43454333

43464334
static const struct file_operations supply_map_fops = {
43474335
#ifdef CONFIG_DEBUG_FS
4348-
.read = supply_map_read_file,
4349-
.llseek = default_llseek,
4336+
.open = supply_map_open,
4337+
.read = seq_read,
4338+
.llseek = seq_lseek,
4339+
.release = single_release,
43504340
#endif
43514341
};
43524342

0 commit comments

Comments
 (0)