aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-12-21 18:49:31 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2011-01-12 09:33:05 -0500
commit1130e5b3ff4a7f3f54a48d46e9d0d81b47765bd8 (patch)
tree333918bbdd573be8efdc7004a6018f34bfd70a77 /drivers/regulator
parent21cf891a47ff5e7bd77fdc524a25072c447d56bb (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>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 6066a8f2d5bb..9fa20957847d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/debugfs.h>
20#include <linux/device.h> 21#include <linux/device.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
22#include <linux/err.h> 23#include <linux/err.h>
@@ -47,6 +48,10 @@ static LIST_HEAD(regulator_map_list);
47static bool has_full_constraints; 48static bool has_full_constraints;
48static bool board_wants_dummy_regulator; 49static bool board_wants_dummy_regulator;
49 50
51#ifdef CONFIG_DEBUG_FS
52static struct dentry *debugfs_root;
53#endif
54
50/* 55/*
51 * struct regulator_map 56 * struct regulator_map
52 * 57 *
@@ -2404,6 +2409,23 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
2404 return status; 2409 return status;
2405} 2410}
2406 2411
2412static void rdev_init_debugfs(struct regulator_dev *rdev)
2413{
2414#ifdef CONFIG_DEBUG_FS
2415 rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root);
2416 if (IS_ERR(rdev->debugfs) || !rdev->debugfs) {
2417 rdev_warn(rdev, "Failed to create debugfs directory\n");
2418 rdev->debugfs = NULL;
2419 return;
2420 }
2421
2422 debugfs_create_u32("use_count", 0444, rdev->debugfs,
2423 &rdev->use_count);
2424 debugfs_create_u32("open_count", 0444, rdev->debugfs,
2425 &rdev->open_count);
2426#endif
2427}
2428
2407/** 2429/**
2408 * regulator_register - register regulator 2430 * regulator_register - register regulator
2409 * @regulator_desc: regulator to register 2431 * @regulator_desc: regulator to register
@@ -2548,6 +2570,8 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
2548 } 2570 }
2549 2571
2550 list_add(&rdev->list, &regulator_list); 2572 list_add(&rdev->list, &regulator_list);
2573
2574 rdev_init_debugfs(rdev);
2551out: 2575out:
2552 mutex_unlock(&regulator_list_mutex); 2576 mutex_unlock(&regulator_list_mutex);
2553 return rdev; 2577 return rdev;
@@ -2580,6 +2604,9 @@ void regulator_unregister(struct regulator_dev *rdev)
2580 return; 2604 return;
2581 2605
2582 mutex_lock(&regulator_list_mutex); 2606 mutex_lock(&regulator_list_mutex);
2607#ifdef CONFIG_DEBUG_FS
2608 debugfs_remove_recursive(rdev->debugfs);
2609#endif
2583 WARN_ON(rdev->open_count); 2610 WARN_ON(rdev->open_count);
2584 unset_regulator_supplies(rdev); 2611 unset_regulator_supplies(rdev);
2585 list_del(&rdev->list); 2612 list_del(&rdev->list);
@@ -2723,6 +2750,14 @@ static int __init regulator_init(void)
2723 2750
2724 ret = class_register(&regulator_class); 2751 ret = class_register(&regulator_class);
2725 2752
2753#ifdef CONFIG_DEBUG_FS
2754 debugfs_root = debugfs_create_dir("regulator", NULL);
2755 if (IS_ERR(debugfs_root) || !debugfs_root) {
2756 pr_warn("regulator: Failed to create debugfs directory\n");
2757 debugfs_root = NULL;
2758 }
2759#endif
2760
2726 regulator_dummy_init(); 2761 regulator_dummy_init();
2727 2762
2728 return ret; 2763 return ret;