aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2012-02-21 01:50:42 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-21 04:56:51 -0500
commit247514344492a0cf602317d2089bab1301922624 (patch)
tree7628c5bf0f4c0726a46145e7734d21d11f6bf006 /drivers/regulator/core.c
parentf4d562c6e616bb686f43d38752b2e5b83359e1fc (diff)
regulator: Remove ifdefs for debugfs code
If CONFIG_DEBUG_FS=y debugfs functions will never return an ERR_PTR. Instead they'll return NULL. The intent is to remove ifdefs in calling code. Update the code to reflect this. We gain an extra dentry pointer per struct regulator and struct regulator_dev but that should be ok because most distros have debugfs compiled in anyway. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 81ea66dcca9c..603e39f81ce0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -52,9 +52,7 @@ static LIST_HEAD(regulator_map_list);
52static bool has_full_constraints; 52static bool has_full_constraints;
53static bool board_wants_dummy_regulator; 53static bool board_wants_dummy_regulator;
54 54
55#ifdef CONFIG_DEBUG_FS
56static struct dentry *debugfs_root; 55static struct dentry *debugfs_root;
57#endif
58 56
59/* 57/*
60 * struct regulator_map 58 * struct regulator_map
@@ -82,9 +80,7 @@ struct regulator {
82 char *supply_name; 80 char *supply_name;
83 struct device_attribute dev_attr; 81 struct device_attribute dev_attr;
84 struct regulator_dev *rdev; 82 struct regulator_dev *rdev;
85#ifdef CONFIG_DEBUG_FS
86 struct dentry *debugfs; 83 struct dentry *debugfs;
87#endif
88}; 84};
89 85
90static int _regulator_is_enabled(struct regulator_dev *rdev); 86static int _regulator_is_enabled(struct regulator_dev *rdev);
@@ -1145,12 +1141,10 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1145 goto attr_err; 1141 goto attr_err;
1146 } 1142 }
1147 1143
1148#ifdef CONFIG_DEBUG_FS
1149 regulator->debugfs = debugfs_create_dir(regulator->supply_name, 1144 regulator->debugfs = debugfs_create_dir(regulator->supply_name,
1150 rdev->debugfs); 1145 rdev->debugfs);
1151 if (IS_ERR_OR_NULL(regulator->debugfs)) { 1146 if (!regulator->debugfs) {
1152 rdev_warn(rdev, "Failed to create debugfs directory\n"); 1147 rdev_warn(rdev, "Failed to create debugfs directory\n");
1153 regulator->debugfs = NULL;
1154 } else { 1148 } else {
1155 debugfs_create_u32("uA_load", 0444, regulator->debugfs, 1149 debugfs_create_u32("uA_load", 0444, regulator->debugfs,
1156 &regulator->uA_load); 1150 &regulator->uA_load);
@@ -1159,7 +1153,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1159 debugfs_create_u32("max_uV", 0444, regulator->debugfs, 1153 debugfs_create_u32("max_uV", 0444, regulator->debugfs,
1160 &regulator->max_uV); 1154 &regulator->max_uV);
1161 } 1155 }
1162#endif
1163 1156
1164 mutex_unlock(&rdev->mutex); 1157 mutex_unlock(&rdev->mutex);
1165 return regulator; 1158 return regulator;
@@ -1368,9 +1361,7 @@ void regulator_put(struct regulator *regulator)
1368 mutex_lock(&regulator_list_mutex); 1361 mutex_lock(&regulator_list_mutex);
1369 rdev = regulator->rdev; 1362 rdev = regulator->rdev;
1370 1363
1371#ifdef CONFIG_DEBUG_FS
1372 debugfs_remove_recursive(regulator->debugfs); 1364 debugfs_remove_recursive(regulator->debugfs);
1373#endif
1374 1365
1375 /* remove any sysfs entries */ 1366 /* remove any sysfs entries */
1376 if (regulator->dev) { 1367 if (regulator->dev) {
@@ -2710,11 +2701,9 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
2710 2701
2711static void rdev_init_debugfs(struct regulator_dev *rdev) 2702static void rdev_init_debugfs(struct regulator_dev *rdev)
2712{ 2703{
2713#ifdef CONFIG_DEBUG_FS
2714 rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root); 2704 rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root);
2715 if (IS_ERR_OR_NULL(rdev->debugfs)) { 2705 if (!rdev->debugfs) {
2716 rdev_warn(rdev, "Failed to create debugfs directory\n"); 2706 rdev_warn(rdev, "Failed to create debugfs directory\n");
2717 rdev->debugfs = NULL;
2718 return; 2707 return;
2719 } 2708 }
2720 2709
@@ -2722,7 +2711,6 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
2722 &rdev->use_count); 2711 &rdev->use_count);
2723 debugfs_create_u32("open_count", 0444, rdev->debugfs, 2712 debugfs_create_u32("open_count", 0444, rdev->debugfs,
2724 &rdev->open_count); 2713 &rdev->open_count);
2725#endif
2726} 2714}
2727 2715
2728/** 2716/**
@@ -2900,9 +2888,7 @@ void regulator_unregister(struct regulator_dev *rdev)
2900 return; 2888 return;
2901 2889
2902 mutex_lock(&regulator_list_mutex); 2890 mutex_lock(&regulator_list_mutex);
2903#ifdef CONFIG_DEBUG_FS
2904 debugfs_remove_recursive(rdev->debugfs); 2891 debugfs_remove_recursive(rdev->debugfs);
2905#endif
2906 flush_work_sync(&rdev->disable_work.work); 2892 flush_work_sync(&rdev->disable_work.work);
2907 WARN_ON(rdev->open_count); 2893 WARN_ON(rdev->open_count);
2908 unset_regulator_supplies(rdev); 2894 unset_regulator_supplies(rdev);
@@ -3112,12 +3098,14 @@ static ssize_t supply_map_read_file(struct file *file, char __user *user_buf,
3112 3098
3113 return ret; 3099 return ret;
3114} 3100}
3101#endif
3115 3102
3116static const struct file_operations supply_map_fops = { 3103static const struct file_operations supply_map_fops = {
3104#ifdef CONFIG_DEBUG_FS
3117 .read = supply_map_read_file, 3105 .read = supply_map_read_file,
3118 .llseek = default_llseek, 3106 .llseek = default_llseek,
3119};
3120#endif 3107#endif
3108};
3121 3109
3122static int __init regulator_init(void) 3110static int __init regulator_init(void)
3123{ 3111{
@@ -3125,16 +3113,12 @@ static int __init regulator_init(void)
3125 3113
3126 ret = class_register(&regulator_class); 3114 ret = class_register(&regulator_class);
3127 3115
3128#ifdef CONFIG_DEBUG_FS
3129 debugfs_root = debugfs_create_dir("regulator", NULL); 3116 debugfs_root = debugfs_create_dir("regulator", NULL);
3130 if (IS_ERR_OR_NULL(debugfs_root)) { 3117 if (!debugfs_root)
3131 pr_warn("regulator: Failed to create debugfs directory\n"); 3118 pr_warn("regulator: Failed to create debugfs directory\n");
3132 debugfs_root = NULL;
3133 }
3134 3119
3135 debugfs_create_file("supply_map", 0444, debugfs_root, NULL, 3120 debugfs_create_file("supply_map", 0444, debugfs_root, NULL,
3136 &supply_map_fops); 3121 &supply_map_fops);
3137#endif
3138 3122
3139 regulator_dummy_init(); 3123 regulator_dummy_init();
3140 3124