@@ -3581,7 +3581,7 @@ struct dentry *tracing_dentry_percpu(void)
35813581static void tracing_init_debugfs_percpu (long cpu )
35823582{
35833583 struct dentry * d_percpu = tracing_dentry_percpu ();
3584- struct dentry * entry , * d_cpu ;
3584+ struct dentry * d_cpu ;
35853585 /* strlen(cpu) + MAX(log10(cpu)) + '\0' */
35863586 char cpu_dir [7 ];
35873587
@@ -3596,21 +3596,15 @@ static void tracing_init_debugfs_percpu(long cpu)
35963596 }
35973597
35983598 /* per cpu trace_pipe */
3599- entry = debugfs_create_file ("trace_pipe" , 0444 , d_cpu ,
3600- (void * ) cpu , & tracing_pipe_fops );
3601- if (!entry )
3602- pr_warning ("Could not create debugfs 'trace_pipe' entry\n" );
3599+ trace_create_file ("trace_pipe" , 0444 , d_cpu ,
3600+ (void * ) cpu , & tracing_pipe_fops );
36033601
36043602 /* per cpu trace */
3605- entry = debugfs_create_file ("trace" , 0644 , d_cpu ,
3606- (void * ) cpu , & tracing_fops );
3607- if (!entry )
3608- pr_warning ("Could not create debugfs 'trace' entry\n" );
3603+ trace_create_file ("trace" , 0644 , d_cpu ,
3604+ (void * ) cpu , & tracing_fops );
36093605
3610- entry = debugfs_create_file ("trace_pipe_raw" , 0444 , d_cpu ,
3611- (void * ) cpu , & tracing_buffers_fops );
3612- if (!entry )
3613- pr_warning ("Could not create debugfs 'trace_pipe_raw' entry\n" );
3606+ trace_create_file ("trace_pipe_raw" , 0444 , d_cpu ,
3607+ (void * ) cpu , & tracing_buffers_fops );
36143608}
36153609
36163610#ifdef CONFIG_FTRACE_SELFTEST
@@ -3766,6 +3760,22 @@ static const struct file_operations trace_options_core_fops = {
37663760 .write = trace_options_core_write ,
37673761};
37683762
3763+ struct dentry * trace_create_file (const char * name ,
3764+ mode_t mode ,
3765+ struct dentry * parent ,
3766+ void * data ,
3767+ const struct file_operations * fops )
3768+ {
3769+ struct dentry * ret ;
3770+
3771+ ret = debugfs_create_file (name , mode , parent , data , fops );
3772+ if (!ret )
3773+ pr_warning ("Could not create debugfs '%s' entry\n" , name );
3774+
3775+ return ret ;
3776+ }
3777+
3778+
37693779static struct dentry * trace_options_init_dentry (void )
37703780{
37713781 struct dentry * d_tracer ;
@@ -3793,7 +3803,6 @@ create_trace_option_file(struct trace_option_dentry *topt,
37933803 struct tracer_opt * opt )
37943804{
37953805 struct dentry * t_options ;
3796- struct dentry * entry ;
37973806
37983807 t_options = trace_options_init_dentry ();
37993808 if (!t_options )
@@ -3802,11 +3811,9 @@ create_trace_option_file(struct trace_option_dentry *topt,
38023811 topt -> flags = flags ;
38033812 topt -> opt = opt ;
38043813
3805- entry = debugfs_create_file (opt -> name , 0644 , t_options , topt ,
3814+ topt -> entry = trace_create_file (opt -> name , 0644 , t_options , topt ,
38063815 & trace_options_fops );
38073816
3808- topt -> entry = entry ;
3809-
38103817}
38113818
38123819static struct trace_option_dentry *
@@ -3861,123 +3868,81 @@ static struct dentry *
38613868create_trace_option_core_file (const char * option , long index )
38623869{
38633870 struct dentry * t_options ;
3864- struct dentry * entry ;
38653871
38663872 t_options = trace_options_init_dentry ();
38673873 if (!t_options )
38683874 return NULL ;
38693875
3870- entry = debugfs_create_file (option , 0644 , t_options , (void * )index ,
3876+ return trace_create_file (option , 0644 , t_options , (void * )index ,
38713877 & trace_options_core_fops );
3872-
3873- return entry ;
38743878}
38753879
38763880static __init void create_trace_options_dir (void )
38773881{
38783882 struct dentry * t_options ;
3879- struct dentry * entry ;
38803883 int i ;
38813884
38823885 t_options = trace_options_init_dentry ();
38833886 if (!t_options )
38843887 return ;
38853888
3886- for (i = 0 ; trace_options [i ]; i ++ ) {
3887- entry = create_trace_option_core_file (trace_options [i ], i );
3888- if (!entry )
3889- pr_warning ("Could not create debugfs %s entry\n" ,
3890- trace_options [i ]);
3891- }
3889+ for (i = 0 ; trace_options [i ]; i ++ )
3890+ create_trace_option_core_file (trace_options [i ], i );
38923891}
38933892
38943893static __init int tracer_init_debugfs (void )
38953894{
38963895 struct dentry * d_tracer ;
3897- struct dentry * entry ;
38983896 int cpu ;
38993897
39003898 d_tracer = tracing_init_dentry ();
39013899
3902- entry = debugfs_create_file ("tracing_enabled" , 0644 , d_tracer ,
3903- & global_trace , & tracing_ctrl_fops );
3904- if (!entry )
3905- pr_warning ("Could not create debugfs 'tracing_enabled' entry\n" );
3900+ trace_create_file ("tracing_enabled" , 0644 , d_tracer ,
3901+ & global_trace , & tracing_ctrl_fops );
39063902
3907- entry = debugfs_create_file ("trace_options" , 0644 , d_tracer ,
3908- NULL , & tracing_iter_fops );
3909- if (!entry )
3910- pr_warning ("Could not create debugfs 'trace_options' entry\n" );
3903+ trace_create_file ("trace_options" , 0644 , d_tracer ,
3904+ NULL , & tracing_iter_fops );
39113905
3912- create_trace_options_dir ();
3906+ trace_create_file ("tracing_cpumask" , 0644 , d_tracer ,
3907+ NULL , & tracing_cpumask_fops );
3908+
3909+ trace_create_file ("trace" , 0644 , d_tracer ,
3910+ (void * ) TRACE_PIPE_ALL_CPU , & tracing_fops );
3911+
3912+ trace_create_file ("available_tracers" , 0444 , d_tracer ,
3913+ & global_trace , & show_traces_fops );
3914+
3915+ trace_create_file ("current_tracer" , 0444 , d_tracer ,
3916+ & global_trace , & set_tracer_fops );
3917+
3918+ trace_create_file ("tracing_max_latency" , 0644 , d_tracer ,
3919+ & tracing_max_latency , & tracing_max_lat_fops );
3920+
3921+ trace_create_file ("tracing_thresh" , 0644 , d_tracer ,
3922+ & tracing_thresh , & tracing_max_lat_fops );
39133923
3914- entry = debugfs_create_file ("tracing_cpumask" , 0644 , d_tracer ,
3915- NULL , & tracing_cpumask_fops );
3916- if (!entry )
3917- pr_warning ("Could not create debugfs 'tracing_cpumask' entry\n" );
3918-
3919- entry = debugfs_create_file ("trace" , 0644 , d_tracer ,
3920- (void * ) TRACE_PIPE_ALL_CPU , & tracing_fops );
3921- if (!entry )
3922- pr_warning ("Could not create debugfs 'trace' entry\n" );
3923-
3924- entry = debugfs_create_file ("available_tracers" , 0444 , d_tracer ,
3925- & global_trace , & show_traces_fops );
3926- if (!entry )
3927- pr_warning ("Could not create debugfs 'available_tracers' entry\n" );
3928-
3929- entry = debugfs_create_file ("current_tracer" , 0444 , d_tracer ,
3930- & global_trace , & set_tracer_fops );
3931- if (!entry )
3932- pr_warning ("Could not create debugfs 'current_tracer' entry\n" );
3933-
3934- entry = debugfs_create_file ("tracing_max_latency" , 0644 , d_tracer ,
3935- & tracing_max_latency ,
3936- & tracing_max_lat_fops );
3937- if (!entry )
3938- pr_warning ("Could not create debugfs "
3939- "'tracing_max_latency' entry\n" );
3940-
3941- entry = debugfs_create_file ("tracing_thresh" , 0644 , d_tracer ,
3942- & tracing_thresh , & tracing_max_lat_fops );
3943- if (!entry )
3944- pr_warning ("Could not create debugfs "
3945- "'tracing_thresh' entry\n" );
3946- entry = debugfs_create_file ("README" , 0644 , d_tracer ,
3947- NULL , & tracing_readme_fops );
3948- if (!entry )
3949- pr_warning ("Could not create debugfs 'README' entry\n" );
3950-
3951- entry = debugfs_create_file ("trace_pipe" , 0444 , d_tracer ,
3924+ trace_create_file ("README" , 0644 , d_tracer ,
3925+ NULL , & tracing_readme_fops );
3926+
3927+ trace_create_file ("trace_pipe" , 0444 , d_tracer ,
39523928 (void * ) TRACE_PIPE_ALL_CPU , & tracing_pipe_fops );
3953- if (!entry )
3954- pr_warning ("Could not create debugfs "
3955- "'trace_pipe' entry\n" );
3956-
3957- entry = debugfs_create_file ("buffer_size_kb" , 0644 , d_tracer ,
3958- & global_trace , & tracing_entries_fops );
3959- if (!entry )
3960- pr_warning ("Could not create debugfs "
3961- "'buffer_size_kb' entry\n" );
3962-
3963- entry = debugfs_create_file ("trace_marker" , 0220 , d_tracer ,
3964- NULL , & tracing_mark_fops );
3965- if (!entry )
3966- pr_warning ("Could not create debugfs "
3967- "'trace_marker' entry\n" );
3929+
3930+ trace_create_file ("buffer_size_kb" , 0644 , d_tracer ,
3931+ & global_trace , & tracing_entries_fops );
3932+
3933+ trace_create_file ("trace_marker" , 0220 , d_tracer ,
3934+ NULL , & tracing_mark_fops );
39683935
39693936#ifdef CONFIG_DYNAMIC_FTRACE
3970- entry = debugfs_create_file ("dyn_ftrace_total_info" , 0444 , d_tracer ,
3971- & ftrace_update_tot_cnt ,
3972- & tracing_dyn_info_fops );
3973- if (!entry )
3974- pr_warning ("Could not create debugfs "
3975- "'dyn_ftrace_total_info' entry\n" );
3937+ trace_create_file ("dyn_ftrace_total_info" , 0444 , d_tracer ,
3938+ & ftrace_update_tot_cnt , & tracing_dyn_info_fops );
39763939#endif
39773940#ifdef CONFIG_SYSPROF_TRACER
39783941 init_tracer_sysprof_debugfs (d_tracer );
39793942#endif
39803943
3944+ create_trace_options_dir ();
3945+
39813946 for_each_tracing_cpu (cpu )
39823947 tracing_init_debugfs_percpu (cpu );
39833948
0 commit comments