1010#include <asm/current.h>
1111#include <linux/dcache.h>
1212#include <linux/debugfs.h>
13- #include <linux/err.h>
1413#include <linux/errno.h>
1514#include <linux/export.h>
1615#include <linux/fs.h>
@@ -293,31 +292,13 @@ static struct batadv_debuginfo *batadv_hardif_debuginfos[] = {
293292void batadv_debugfs_init (void )
294293{
295294 struct batadv_debuginfo * * bat_debug ;
296- struct dentry * file ;
297295
298296 batadv_debugfs = debugfs_create_dir (BATADV_DEBUGFS_SUBDIR , NULL );
299- if (batadv_debugfs == ERR_PTR (- ENODEV ))
300- batadv_debugfs = NULL ;
301-
302- if (!batadv_debugfs )
303- goto err ;
304-
305- for (bat_debug = batadv_general_debuginfos ; * bat_debug ; ++ bat_debug ) {
306- file = debugfs_create_file (((* bat_debug )-> attr ).name ,
307- S_IFREG | ((* bat_debug )-> attr ).mode ,
308- batadv_debugfs , NULL ,
309- & (* bat_debug )-> fops );
310- if (!file ) {
311- pr_err ("Can't add general debugfs file: %s\n" ,
312- ((* bat_debug )-> attr ).name );
313- goto err ;
314- }
315- }
316297
317- return ;
318- err :
319- debugfs_remove_recursive ( batadv_debugfs );
320- batadv_debugfs = NULL ;
298+ for ( bat_debug = batadv_general_debuginfos ; * bat_debug ; ++ bat_debug )
299+ debugfs_create_file ((( * bat_debug ) -> attr ). name ,
300+ S_IFREG | (( * bat_debug ) -> attr ). mode ,
301+ batadv_debugfs , NULL , & ( * bat_debug ) -> fops ) ;
321302}
322303
323304/**
@@ -333,42 +314,23 @@ void batadv_debugfs_destroy(void)
333314 * batadv_debugfs_add_hardif() - creates the base directory for a hard interface
334315 * in debugfs.
335316 * @hard_iface: hard interface which should be added.
336- *
337- * Return: 0 on success or negative error number in case of failure
338317 */
339- int batadv_debugfs_add_hardif (struct batadv_hard_iface * hard_iface )
318+ void batadv_debugfs_add_hardif (struct batadv_hard_iface * hard_iface )
340319{
341320 struct net * net = dev_net (hard_iface -> net_dev );
342321 struct batadv_debuginfo * * bat_debug ;
343- struct dentry * file ;
344-
345- if (!batadv_debugfs )
346- goto out ;
347322
348323 if (net != & init_net )
349- return 0 ;
324+ return ;
350325
351326 hard_iface -> debug_dir = debugfs_create_dir (hard_iface -> net_dev -> name ,
352327 batadv_debugfs );
353- if (!hard_iface -> debug_dir )
354- goto out ;
355-
356- for (bat_debug = batadv_hardif_debuginfos ; * bat_debug ; ++ bat_debug ) {
357- file = debugfs_create_file (((* bat_debug )-> attr ).name ,
358- S_IFREG | ((* bat_debug )-> attr ).mode ,
359- hard_iface -> debug_dir ,
360- hard_iface -> net_dev ,
361- & (* bat_debug )-> fops );
362- if (!file )
363- goto rem_attr ;
364- }
365328
366- return 0 ;
367- rem_attr :
368- debugfs_remove_recursive (hard_iface -> debug_dir );
369- hard_iface -> debug_dir = NULL ;
370- out :
371- return - ENOMEM ;
329+ for (bat_debug = batadv_hardif_debuginfos ; * bat_debug ; ++ bat_debug )
330+ debugfs_create_file (((* bat_debug )-> attr ).name ,
331+ S_IFREG | ((* bat_debug )-> attr ).mode ,
332+ hard_iface -> debug_dir , hard_iface -> net_dev ,
333+ & (* bat_debug )-> fops );
372334}
373335
374336/**
@@ -379,15 +341,12 @@ void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface)
379341{
380342 const char * name = hard_iface -> net_dev -> name ;
381343 struct dentry * dir ;
382- struct dentry * d ;
383344
384345 dir = hard_iface -> debug_dir ;
385346 if (!dir )
386347 return ;
387348
388- d = debugfs_rename (dir -> d_parent , dir , dir -> d_parent , name );
389- if (!d )
390- pr_err ("Can't rename debugfs dir to %s\n" , name );
349+ debugfs_rename (dir -> d_parent , dir , dir -> d_parent , name );
391350}
392351
393352/**
@@ -419,44 +378,29 @@ int batadv_debugfs_add_meshif(struct net_device *dev)
419378 struct batadv_priv * bat_priv = netdev_priv (dev );
420379 struct batadv_debuginfo * * bat_debug ;
421380 struct net * net = dev_net (dev );
422- struct dentry * file ;
423-
424- if (!batadv_debugfs )
425- goto out ;
426381
427382 if (net != & init_net )
428383 return 0 ;
429384
430385 bat_priv -> debug_dir = debugfs_create_dir (dev -> name , batadv_debugfs );
431- if (!bat_priv -> debug_dir )
432- goto out ;
433386
434- if (batadv_socket_setup (bat_priv ) < 0 )
435- goto rem_attr ;
387+ batadv_socket_setup (bat_priv );
436388
437389 if (batadv_debug_log_setup (bat_priv ) < 0 )
438390 goto rem_attr ;
439391
440- for (bat_debug = batadv_mesh_debuginfos ; * bat_debug ; ++ bat_debug ) {
441- file = debugfs_create_file (((* bat_debug )-> attr ).name ,
442- S_IFREG | ((* bat_debug )-> attr ).mode ,
443- bat_priv -> debug_dir ,
444- dev , & (* bat_debug )-> fops );
445- if (!file ) {
446- batadv_err (dev , "Can't add debugfs file: %s/%s\n" ,
447- dev -> name , ((* bat_debug )-> attr ).name );
448- goto rem_attr ;
449- }
450- }
392+ for (bat_debug = batadv_mesh_debuginfos ; * bat_debug ; ++ bat_debug )
393+ debugfs_create_file (((* bat_debug )-> attr ).name ,
394+ S_IFREG | ((* bat_debug )-> attr ).mode ,
395+ bat_priv -> debug_dir , dev ,
396+ & (* bat_debug )-> fops );
451397
452- if (batadv_nc_init_debugfs (bat_priv ) < 0 )
453- goto rem_attr ;
398+ batadv_nc_init_debugfs (bat_priv );
454399
455400 return 0 ;
456401rem_attr :
457402 debugfs_remove_recursive (bat_priv -> debug_dir );
458403 bat_priv -> debug_dir = NULL ;
459- out :
460404 return - ENOMEM ;
461405}
462406
@@ -469,15 +413,12 @@ void batadv_debugfs_rename_meshif(struct net_device *dev)
469413 struct batadv_priv * bat_priv = netdev_priv (dev );
470414 const char * name = dev -> name ;
471415 struct dentry * dir ;
472- struct dentry * d ;
473416
474417 dir = bat_priv -> debug_dir ;
475418 if (!dir )
476419 return ;
477420
478- d = debugfs_rename (dir -> d_parent , dir , dir -> d_parent , name );
479- if (!d )
480- pr_err ("Can't rename debugfs dir to %s\n" , name );
421+ debugfs_rename (dir -> d_parent , dir , dir -> d_parent , name );
481422}
482423
483424/**
0 commit comments