21
21
#include <linux/suspend.h>
22
22
#include <linux/export.h>
23
23
#include <linux/cpu.h>
24
+ #include <linux/debugfs.h>
24
25
25
26
#include "power.h"
26
27
@@ -210,6 +211,18 @@ static void genpd_sd_counter_inc(struct generic_pm_domain *genpd)
210
211
}
211
212
212
213
#ifdef CONFIG_DEBUG_FS
214
+ static struct dentry * genpd_debugfs_dir ;
215
+
216
+ static void genpd_debug_add (struct generic_pm_domain * genpd );
217
+
218
+ static void genpd_debug_remove (struct generic_pm_domain * genpd )
219
+ {
220
+ struct dentry * d ;
221
+
222
+ d = debugfs_lookup (genpd -> name , genpd_debugfs_dir );
223
+ debugfs_remove (d );
224
+ }
225
+
213
226
static void genpd_update_accounting (struct generic_pm_domain * genpd )
214
227
{
215
228
ktime_t delta , now ;
@@ -234,6 +247,8 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd)
234
247
genpd -> accounting_time = now ;
235
248
}
236
249
#else
250
+ static inline void genpd_debug_add (struct generic_pm_domain * genpd ) {}
251
+ static inline void genpd_debug_remove (struct generic_pm_domain * genpd ) {}
237
252
static inline void genpd_update_accounting (struct generic_pm_domain * genpd ) {}
238
253
#endif
239
254
@@ -1954,6 +1969,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
1954
1969
1955
1970
mutex_lock (& gpd_list_lock );
1956
1971
list_add (& genpd -> gpd_list_node , & gpd_list );
1972
+ genpd_debug_add (genpd );
1957
1973
mutex_unlock (& gpd_list_lock );
1958
1974
1959
1975
return 0 ;
@@ -1987,6 +2003,7 @@ static int genpd_remove(struct generic_pm_domain *genpd)
1987
2003
kfree (link );
1988
2004
}
1989
2005
2006
+ genpd_debug_remove (genpd );
1990
2007
list_del (& genpd -> gpd_list_node );
1991
2008
genpd_unlock (genpd );
1992
2009
cancel_work_sync (& genpd -> power_off_work );
@@ -2893,14 +2910,6 @@ core_initcall(genpd_bus_init);
2893
2910
/*** debugfs support ***/
2894
2911
2895
2912
#ifdef CONFIG_DEBUG_FS
2896
- #include <linux/pm.h>
2897
- #include <linux/device.h>
2898
- #include <linux/debugfs.h>
2899
- #include <linux/seq_file.h>
2900
- #include <linux/init.h>
2901
- #include <linux/kobject.h>
2902
- static struct dentry * genpd_debugfs_dir ;
2903
-
2904
2913
/*
2905
2914
* TODO: This function is a slightly modified version of rtpm_status_show
2906
2915
* from sysfs.c, so generalize it.
@@ -3177,35 +3186,43 @@ DEFINE_SHOW_ATTRIBUTE(total_idle_time);
3177
3186
DEFINE_SHOW_ATTRIBUTE (devices );
3178
3187
DEFINE_SHOW_ATTRIBUTE (perf_state );
3179
3188
3180
- static int __init genpd_debug_init ( void )
3189
+ static void genpd_debug_add ( struct generic_pm_domain * genpd )
3181
3190
{
3182
3191
struct dentry * d ;
3192
+
3193
+ if (!genpd_debugfs_dir )
3194
+ return ;
3195
+
3196
+ d = debugfs_create_dir (genpd -> name , genpd_debugfs_dir );
3197
+
3198
+ debugfs_create_file ("current_state" , 0444 ,
3199
+ d , genpd , & status_fops );
3200
+ debugfs_create_file ("sub_domains" , 0444 ,
3201
+ d , genpd , & sub_domains_fops );
3202
+ debugfs_create_file ("idle_states" , 0444 ,
3203
+ d , genpd , & idle_states_fops );
3204
+ debugfs_create_file ("active_time" , 0444 ,
3205
+ d , genpd , & active_time_fops );
3206
+ debugfs_create_file ("total_idle_time" , 0444 ,
3207
+ d , genpd , & total_idle_time_fops );
3208
+ debugfs_create_file ("devices" , 0444 ,
3209
+ d , genpd , & devices_fops );
3210
+ if (genpd -> set_performance_state )
3211
+ debugfs_create_file ("perf_state" , 0444 ,
3212
+ d , genpd , & perf_state_fops );
3213
+ }
3214
+
3215
+ static int __init genpd_debug_init (void )
3216
+ {
3183
3217
struct generic_pm_domain * genpd ;
3184
3218
3185
3219
genpd_debugfs_dir = debugfs_create_dir ("pm_genpd" , NULL );
3186
3220
3187
3221
debugfs_create_file ("pm_genpd_summary" , S_IRUGO , genpd_debugfs_dir ,
3188
3222
NULL , & summary_fops );
3189
3223
3190
- list_for_each_entry (genpd , & gpd_list , gpd_list_node ) {
3191
- d = debugfs_create_dir (genpd -> name , genpd_debugfs_dir );
3192
-
3193
- debugfs_create_file ("current_state" , 0444 ,
3194
- d , genpd , & status_fops );
3195
- debugfs_create_file ("sub_domains" , 0444 ,
3196
- d , genpd , & sub_domains_fops );
3197
- debugfs_create_file ("idle_states" , 0444 ,
3198
- d , genpd , & idle_states_fops );
3199
- debugfs_create_file ("active_time" , 0444 ,
3200
- d , genpd , & active_time_fops );
3201
- debugfs_create_file ("total_idle_time" , 0444 ,
3202
- d , genpd , & total_idle_time_fops );
3203
- debugfs_create_file ("devices" , 0444 ,
3204
- d , genpd , & devices_fops );
3205
- if (genpd -> set_performance_state )
3206
- debugfs_create_file ("perf_state" , 0444 ,
3207
- d , genpd , & perf_state_fops );
3208
- }
3224
+ list_for_each_entry (genpd , & gpd_list , gpd_list_node )
3225
+ genpd_debug_add (genpd );
3209
3226
3210
3227
return 0 ;
3211
3228
}
0 commit comments