diff options
author | Antonio Quartulli <ordex@autistici.org> | 2012-10-16 04:04:39 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-11-21 06:34:49 -0500 |
commit | 637fbd12947b5645d8c16c982aa15c17ab695b0a (patch) | |
tree | a8445d72399cb574cfac136e911bfd5a65ed3fc9 /net/batman-adv | |
parent | c76d15253aeaf8ee3beee932d1950296431bec96 (diff) |
batman-adv: support array of debugfs general attributes
This patch adds support for an array of debugfs general (not soft_iface
specific) attributes. With this change it will be possible to add more general
attributes by simply appending them to the array without touching the rest of
the code.
Reported-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Acked-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/debugfs.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index 3f679cb2d0e2..6f58ddd53bff 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c | |||
@@ -323,7 +323,17 @@ struct batadv_debuginfo batadv_debuginfo_##_name = { \ | |||
323 | } \ | 323 | } \ |
324 | }; | 324 | }; |
325 | 325 | ||
326 | /* the following attributes are general and therefore they will be directly | ||
327 | * placed in the BATADV_DEBUGFS_SUBDIR subdirectory of debugfs | ||
328 | */ | ||
326 | static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); | 329 | static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); |
330 | |||
331 | static struct batadv_debuginfo *batadv_general_debuginfos[] = { | ||
332 | &batadv_debuginfo_routing_algos, | ||
333 | NULL, | ||
334 | }; | ||
335 | |||
336 | /* The following attributes are per soft interface */ | ||
327 | static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); | 337 | static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); |
328 | static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); | 338 | static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); |
329 | static BATADV_DEBUGINFO(transtable_global, S_IRUGO, | 339 | static BATADV_DEBUGINFO(transtable_global, S_IRUGO, |
@@ -358,7 +368,7 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { | |||
358 | 368 | ||
359 | void batadv_debugfs_init(void) | 369 | void batadv_debugfs_init(void) |
360 | { | 370 | { |
361 | struct batadv_debuginfo *bat_debug; | 371 | struct batadv_debuginfo **bat_debug; |
362 | struct dentry *file; | 372 | struct dentry *file; |
363 | 373 | ||
364 | batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL); | 374 | batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL); |
@@ -366,17 +376,23 @@ void batadv_debugfs_init(void) | |||
366 | batadv_debugfs = NULL; | 376 | batadv_debugfs = NULL; |
367 | 377 | ||
368 | if (!batadv_debugfs) | 378 | if (!batadv_debugfs) |
369 | goto out; | 379 | goto err; |
370 | 380 | ||
371 | bat_debug = &batadv_debuginfo_routing_algos; | 381 | for (bat_debug = batadv_general_debuginfos; *bat_debug; ++bat_debug) { |
372 | file = debugfs_create_file(bat_debug->attr.name, | 382 | file = debugfs_create_file(((*bat_debug)->attr).name, |
373 | S_IFREG | bat_debug->attr.mode, | 383 | S_IFREG | ((*bat_debug)->attr).mode, |
374 | batadv_debugfs, NULL, &bat_debug->fops); | 384 | batadv_debugfs, NULL, |
375 | if (!file) | 385 | &(*bat_debug)->fops); |
376 | pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name); | 386 | if (!file) { |
387 | pr_err("Can't add general debugfs file: %s\n", | ||
388 | ((*bat_debug)->attr).name); | ||
389 | goto err; | ||
390 | } | ||
391 | } | ||
377 | 392 | ||
378 | out: | ||
379 | return; | 393 | return; |
394 | err: | ||
395 | debugfs_remove_recursive(batadv_debugfs); | ||
380 | } | 396 | } |
381 | 397 | ||
382 | void batadv_debugfs_destroy(void) | 398 | void batadv_debugfs_destroy(void) |