2121#include <linux/suspend.h>
2222#include <linux/export.h>
2323#include <linux/cpu.h>
24+ #include <linux/debugfs.h>
2425
2526#include "power.h"
2627
@@ -210,6 +211,18 @@ static void genpd_sd_counter_inc(struct generic_pm_domain *genpd)
210211}
211212
212213#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+
213226static void genpd_update_accounting (struct generic_pm_domain * genpd )
214227{
215228 ktime_t delta , now ;
@@ -234,6 +247,8 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd)
234247 genpd -> accounting_time = now ;
235248}
236249#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 ) {}
237252static inline void genpd_update_accounting (struct generic_pm_domain * genpd ) {}
238253#endif
239254
@@ -1142,7 +1157,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff)
11421157 if (ret )
11431158 return ret ;
11441159
1145- if (dev -> power . wakeup_path && genpd_is_active_wakeup (genpd ))
1160+ if (device_wakeup_path ( dev ) && genpd_is_active_wakeup (genpd ))
11461161 return 0 ;
11471162
11481163 if (genpd -> dev_ops .stop && genpd -> dev_ops .start &&
@@ -1196,7 +1211,7 @@ static int genpd_resume_noirq(struct device *dev)
11961211 if (IS_ERR (genpd ))
11971212 return - EINVAL ;
11981213
1199- if (dev -> power . wakeup_path && genpd_is_active_wakeup (genpd ))
1214+ if (device_wakeup_path ( dev ) && genpd_is_active_wakeup (genpd ))
12001215 return pm_generic_resume_noirq (dev );
12011216
12021217 genpd_lock (genpd );
@@ -1973,6 +1988,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
19731988
19741989 mutex_lock (& gpd_list_lock );
19751990 list_add (& genpd -> gpd_list_node , & gpd_list );
1991+ genpd_debug_add (genpd );
19761992 mutex_unlock (& gpd_list_lock );
19771993
19781994 return 0 ;
@@ -2006,6 +2022,7 @@ static int genpd_remove(struct generic_pm_domain *genpd)
20062022 kfree (link );
20072023 }
20082024
2025+ genpd_debug_remove (genpd );
20092026 list_del (& genpd -> gpd_list_node );
20102027 genpd_unlock (genpd );
20112028 cancel_work_sync (& genpd -> power_off_work );
@@ -2912,14 +2929,6 @@ core_initcall(genpd_bus_init);
29122929/*** debugfs support ***/
29132930
29142931#ifdef CONFIG_DEBUG_FS
2915- #include <linux/pm.h>
2916- #include <linux/device.h>
2917- #include <linux/debugfs.h>
2918- #include <linux/seq_file.h>
2919- #include <linux/init.h>
2920- #include <linux/kobject.h>
2921- static struct dentry * genpd_debugfs_dir ;
2922-
29232932/*
29242933 * TODO: This function is a slightly modified version of rtpm_status_show
29252934 * from sysfs.c, so generalize it.
@@ -3196,35 +3205,43 @@ DEFINE_SHOW_ATTRIBUTE(total_idle_time);
31963205DEFINE_SHOW_ATTRIBUTE (devices );
31973206DEFINE_SHOW_ATTRIBUTE (perf_state );
31983207
3199- static int __init genpd_debug_init ( void )
3208+ static void genpd_debug_add ( struct generic_pm_domain * genpd )
32003209{
32013210 struct dentry * d ;
3211+
3212+ if (!genpd_debugfs_dir )
3213+ return ;
3214+
3215+ d = debugfs_create_dir (genpd -> name , genpd_debugfs_dir );
3216+
3217+ debugfs_create_file ("current_state" , 0444 ,
3218+ d , genpd , & status_fops );
3219+ debugfs_create_file ("sub_domains" , 0444 ,
3220+ d , genpd , & sub_domains_fops );
3221+ debugfs_create_file ("idle_states" , 0444 ,
3222+ d , genpd , & idle_states_fops );
3223+ debugfs_create_file ("active_time" , 0444 ,
3224+ d , genpd , & active_time_fops );
3225+ debugfs_create_file ("total_idle_time" , 0444 ,
3226+ d , genpd , & total_idle_time_fops );
3227+ debugfs_create_file ("devices" , 0444 ,
3228+ d , genpd , & devices_fops );
3229+ if (genpd -> set_performance_state )
3230+ debugfs_create_file ("perf_state" , 0444 ,
3231+ d , genpd , & perf_state_fops );
3232+ }
3233+
3234+ static int __init genpd_debug_init (void )
3235+ {
32023236 struct generic_pm_domain * genpd ;
32033237
32043238 genpd_debugfs_dir = debugfs_create_dir ("pm_genpd" , NULL );
32053239
32063240 debugfs_create_file ("pm_genpd_summary" , S_IRUGO , genpd_debugfs_dir ,
32073241 NULL , & summary_fops );
32083242
3209- list_for_each_entry (genpd , & gpd_list , gpd_list_node ) {
3210- d = debugfs_create_dir (genpd -> name , genpd_debugfs_dir );
3211-
3212- debugfs_create_file ("current_state" , 0444 ,
3213- d , genpd , & status_fops );
3214- debugfs_create_file ("sub_domains" , 0444 ,
3215- d , genpd , & sub_domains_fops );
3216- debugfs_create_file ("idle_states" , 0444 ,
3217- d , genpd , & idle_states_fops );
3218- debugfs_create_file ("active_time" , 0444 ,
3219- d , genpd , & active_time_fops );
3220- debugfs_create_file ("total_idle_time" , 0444 ,
3221- d , genpd , & total_idle_time_fops );
3222- debugfs_create_file ("devices" , 0444 ,
3223- d , genpd , & devices_fops );
3224- if (genpd -> set_performance_state )
3225- debugfs_create_file ("perf_state" , 0444 ,
3226- d , genpd , & perf_state_fops );
3227- }
3243+ list_for_each_entry (genpd , & gpd_list , gpd_list_node )
3244+ genpd_debug_add (genpd );
32283245
32293246 return 0 ;
32303247}
0 commit comments