diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-08-23 12:39:10 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-08-28 12:41:59 -0400 |
commit | ba55a9741da6c85176987c15e24383b858749aa2 (patch) | |
tree | a803b08a17c1dd8736bedac87ba60f347127327f /drivers/regulator | |
parent | 500c524aad173864a58e128d0be9713fa5846471 (diff) |
regulator: Add debugfs file showing the supply map table
Useful for working out why things aren't getting plugged together properly.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d8e6a429e8ba..9a33fe2021b6 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -2907,6 +2907,43 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data) | |||
2907 | } | 2907 | } |
2908 | EXPORT_SYMBOL_GPL(regulator_get_init_drvdata); | 2908 | EXPORT_SYMBOL_GPL(regulator_get_init_drvdata); |
2909 | 2909 | ||
2910 | #ifdef CONFIG_DEBUG_FS | ||
2911 | static ssize_t supply_map_read_file(struct file *file, char __user *user_buf, | ||
2912 | size_t count, loff_t *ppos) | ||
2913 | { | ||
2914 | char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
2915 | ssize_t len, ret = 0; | ||
2916 | struct regulator_map *map; | ||
2917 | |||
2918 | if (!buf) | ||
2919 | return -ENOMEM; | ||
2920 | |||
2921 | list_for_each_entry(map, ®ulator_map_list, list) { | ||
2922 | len = snprintf(buf + ret, PAGE_SIZE - ret, | ||
2923 | "%s -> %s.%s\n", | ||
2924 | rdev_get_name(map->regulator), map->dev_name, | ||
2925 | map->supply); | ||
2926 | if (len >= 0) | ||
2927 | ret += len; | ||
2928 | if (ret > PAGE_SIZE) { | ||
2929 | ret = PAGE_SIZE; | ||
2930 | break; | ||
2931 | } | ||
2932 | } | ||
2933 | |||
2934 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); | ||
2935 | |||
2936 | kfree(buf); | ||
2937 | |||
2938 | return ret; | ||
2939 | } | ||
2940 | |||
2941 | static const struct file_operations supply_map_fops = { | ||
2942 | .read = supply_map_read_file, | ||
2943 | .llseek = default_llseek, | ||
2944 | }; | ||
2945 | #endif | ||
2946 | |||
2910 | static int __init regulator_init(void) | 2947 | static int __init regulator_init(void) |
2911 | { | 2948 | { |
2912 | int ret; | 2949 | int ret; |
@@ -2919,6 +2956,10 @@ static int __init regulator_init(void) | |||
2919 | pr_warn("regulator: Failed to create debugfs directory\n"); | 2956 | pr_warn("regulator: Failed to create debugfs directory\n"); |
2920 | debugfs_root = NULL; | 2957 | debugfs_root = NULL; |
2921 | } | 2958 | } |
2959 | |||
2960 | if (IS_ERR(debugfs_create_file("supply_map", 0444, debugfs_root, | ||
2961 | NULL, &supply_map_fops))) | ||
2962 | pr_warn("regulator: Failed to create supplies debugfs\n"); | ||
2922 | #endif | 2963 | #endif |
2923 | 2964 | ||
2924 | regulator_dummy_init(); | 2965 | regulator_dummy_init(); |