diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-12-21 23:49:31 +0000 |
---|---|---|
committer | Niket Sirsi <nsirsi@nvidia.com> | 2011-05-23 16:56:33 -0700 |
commit | d3923800031bb867eceba101b382321e694fa062 (patch) | |
tree | 8d04403714c1c9153d8630c59e6b8cb4736dddf0 /drivers/regulator | |
parent | cbb7d2b75535ed5f293bcac5b5ecd6cafa482f1a (diff) |
regulator: Add initial per-regulator debugfs support
We only expose the use and open counts to userspace, providing a tiny
bit of insight into what the API is up to.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
(cherry picked from commit 1130e5b3ff4a7f3f54a48d46e9d0d81b47765bd8)
Reviewed-on: http://git.kernel.org/?p=linux/kernel/git/torvalds/
linux-2.6.git;a=commit;h=1130e5b3ff4a7f3f54a48d46e9d0d81b47765bd8
Change-Id: I4454e34ee8dca3ea2932fb3b8f3ff8ad668d3147
Reviewed-on: http://git-master/r/30957
Tested-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
Reviewed-by: Daniel Willemsen <dwillemsen@nvidia.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index b5ad1809740e..1a6582f22186 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -15,6 +15,7 @@ #include <linux/kernel.h> #include <linux/init.h> +#include <linux/debugfs.h> #include <linux/device.h> #include <linux/slab.h> #include <linux/err.h> @@ -37,6 +38,10 @@ static LIST_HEAD(regulator_list); static LIST_HEAD(regulator_map_list); static int has_full_constraints; +#ifdef CONFIG_DEBUG_FS +static struct dentry *debugfs_root; +#endif + /* * struct regulator_map * @@ -2295,6 +2300,23 @@ static int add_regulator_attributes(struct regulator_dev *rdev) return status; } +static void rdev_init_debugfs(struct regulator_dev *rdev) +{ +#ifdef CONFIG_DEBUG_FS + rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root); + if (IS_ERR(rdev->debugfs) || !rdev->debugfs) { + printk(KERN_ERR "Failed to create debugfs directory\n"); + rdev->debugfs = NULL; + return; + } + + debugfs_create_u32("use_count", 0444, rdev->debugfs, + &rdev->use_count); + debugfs_create_u32("open_count", 0444, rdev->debugfs, + &rdev->open_count); +#endif +} + /** * regulator_register - register regulator * @regulator_desc: regulator to register @@ -2421,6 +2443,8 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, } list_add(&rdev->list, ®ulator_list); + + rdev_init_debugfs(rdev); out: mutex_unlock(®ulator_list_mutex); return rdev; @@ -2453,6 +2477,9 @@ void regulator_unregister(struct regulator_dev *rdev) return; mutex_lock(®ulator_list_mutex); +#ifdef CONFIG_DEBUG_FS + debugfs_remove_recursive(rdev->debugfs); +#endif WARN_ON(rdev->open_count); unset_regulator_supplies(rdev); list_del(&rdev->list); @@ -2624,6 +2651,14 @@ static int __init regulator_init(void) ret = class_register(®ulator_class); +#ifdef CONFIG_DEBUG_FS + debugfs_root = debugfs_create_dir("regulator", NULL); + if (IS_ERR(debugfs_root) || !debugfs_root) { + pr_warn("regulator: Failed to create debugfs directory\n"); + debugfs_root = NULL; + } +#endif + regulator_dummy_init(); return ret; |