diff options
author | Haishan Zhou <zhssmail@gmail.com> | 2017-06-29 23:43:42 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-06-30 07:56:42 -0400 |
commit | dbc559554086f176b04f97eec561ad26ee54e47c (patch) | |
tree | a955b18c6b9ce14f6446286ea3f96fde5bc11cf3 | |
parent | 062171973e05440673cb997e64395e84a8e66350 (diff) |
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 <zhssmail@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/core.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a0362a63902e..f8e76f73da35 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -4311,41 +4311,31 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data) | |||
4311 | EXPORT_SYMBOL_GPL(regulator_get_init_drvdata); | 4311 | EXPORT_SYMBOL_GPL(regulator_get_init_drvdata); |
4312 | 4312 | ||
4313 | #ifdef CONFIG_DEBUG_FS | 4313 | #ifdef CONFIG_DEBUG_FS |
4314 | static ssize_t supply_map_read_file(struct file *file, char __user *user_buf, | 4314 | static int supply_map_show(struct seq_file *sf, void *data) |
4315 | size_t count, loff_t *ppos) | ||
4316 | { | 4315 | { |
4317 | char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
4318 | ssize_t len, ret = 0; | ||
4319 | struct regulator_map *map; | 4316 | struct regulator_map *map; |
4320 | 4317 | ||
4321 | if (!buf) | ||
4322 | return -ENOMEM; | ||
4323 | |||
4324 | list_for_each_entry(map, ®ulator_map_list, list) { | 4318 | list_for_each_entry(map, ®ulator_map_list, list) { |
4325 | len = snprintf(buf + ret, PAGE_SIZE - ret, | 4319 | seq_printf(sf, "%s -> %s.%s\n", |
4326 | "%s -> %s.%s\n", | 4320 | rdev_get_name(map->regulator), map->dev_name, |
4327 | rdev_get_name(map->regulator), map->dev_name, | 4321 | map->supply); |
4328 | map->supply); | ||
4329 | if (len >= 0) | ||
4330 | ret += len; | ||
4331 | if (ret > PAGE_SIZE) { | ||
4332 | ret = PAGE_SIZE; | ||
4333 | break; | ||
4334 | } | ||
4335 | } | 4322 | } |
4336 | 4323 | ||
4337 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); | 4324 | return 0; |
4338 | 4325 | } | |
4339 | kfree(buf); | ||
4340 | 4326 | ||
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); | ||
4342 | } | 4330 | } |
4343 | #endif | 4331 | #endif |
4344 | 4332 | ||
4345 | static const struct file_operations supply_map_fops = { | 4333 | static const struct file_operations supply_map_fops = { |
4346 | #ifdef CONFIG_DEBUG_FS | 4334 | #ifdef CONFIG_DEBUG_FS |
4347 | .read = supply_map_read_file, | 4335 | .open = supply_map_open, |
4348 | .llseek = default_llseek, | 4336 | .read = seq_read, |
4337 | .llseek = seq_lseek, | ||
4338 | .release = single_release, | ||
4349 | #endif | 4339 | #endif |
4350 | }; | 4340 | }; |
4351 | 4341 | ||