Skip to content

Commit dbc5595

Browse files
chouericbroonie
authored andcommitted
regulator: core: Fix size limit of supply_map
Now the debugfs file supply_map has a size limit PAGE_SIZE and the user can not see the whole content of regulator_map_list when it is larger than this limit. This patch uses seq_file instead to make sure supply_map shows the full information of regulator_map_list. Signed-off-by: Haishan Zhou <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 0621719 commit dbc5595

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

drivers/regulator/core.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4311,41 +4311,31 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
43114311
EXPORT_SYMBOL_GPL(regulator_get_init_drvdata);
43124312

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

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

4337-
ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
4338-
4339-
kfree(buf);
4324+
return 0;
4325+
}
43404326

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

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

0 commit comments

Comments
 (0)