diff options
author | Mark Brown <broonie@linaro.org> | 2013-10-28 16:01:33 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-28 16:01:33 -0400 |
commit | bee54e310e579c8760bc4e8215853c625d8c7895 (patch) | |
tree | 4b540611bcdb3e349cca85cf0f50fbe2e6baae0f /drivers/base | |
parent | 5eff79fe2d239a60c98ec709c769f8e8f952b42f (diff) | |
parent | a52eaeb1898bc0589888ee62de291aa278379004 (diff) |
Merge remote-tracking branch 'regmap/topic/core' into regmap-next
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regmap-debugfs.c | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index de11ecaf3833..c5471cd6ebb7 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c | |||
@@ -15,10 +15,19 @@ | |||
15 | #include <linux/debugfs.h> | 15 | #include <linux/debugfs.h> |
16 | #include <linux/uaccess.h> | 16 | #include <linux/uaccess.h> |
17 | #include <linux/device.h> | 17 | #include <linux/device.h> |
18 | #include <linux/list.h> | ||
18 | 19 | ||
19 | #include "internal.h" | 20 | #include "internal.h" |
20 | 21 | ||
22 | struct regmap_debugfs_node { | ||
23 | struct regmap *map; | ||
24 | const char *name; | ||
25 | struct list_head link; | ||
26 | }; | ||
27 | |||
21 | static struct dentry *regmap_debugfs_root; | 28 | static struct dentry *regmap_debugfs_root; |
29 | static LIST_HEAD(regmap_debugfs_early_list); | ||
30 | static DEFINE_MUTEX(regmap_debugfs_early_lock); | ||
22 | 31 | ||
23 | /* Calculate the length of a fixed format */ | 32 | /* Calculate the length of a fixed format */ |
24 | static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size) | 33 | static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size) |
@@ -465,6 +474,20 @@ void regmap_debugfs_init(struct regmap *map, const char *name) | |||
465 | struct rb_node *next; | 474 | struct rb_node *next; |
466 | struct regmap_range_node *range_node; | 475 | struct regmap_range_node *range_node; |
467 | 476 | ||
477 | /* If we don't have the debugfs root yet, postpone init */ | ||
478 | if (!regmap_debugfs_root) { | ||
479 | struct regmap_debugfs_node *node; | ||
480 | node = kzalloc(sizeof(*node), GFP_KERNEL); | ||
481 | if (!node) | ||
482 | return; | ||
483 | node->map = map; | ||
484 | node->name = name; | ||
485 | mutex_lock(®map_debugfs_early_lock); | ||
486 | list_add(&node->link, ®map_debugfs_early_list); | ||
487 | mutex_unlock(®map_debugfs_early_lock); | ||
488 | return; | ||
489 | } | ||
490 | |||
468 | INIT_LIST_HEAD(&map->debugfs_off_cache); | 491 | INIT_LIST_HEAD(&map->debugfs_off_cache); |
469 | mutex_init(&map->cache_lock); | 492 | mutex_init(&map->cache_lock); |
470 | 493 | ||
@@ -519,18 +542,42 @@ void regmap_debugfs_init(struct regmap *map, const char *name) | |||
519 | 542 | ||
520 | void regmap_debugfs_exit(struct regmap *map) | 543 | void regmap_debugfs_exit(struct regmap *map) |
521 | { | 544 | { |
522 | debugfs_remove_recursive(map->debugfs); | 545 | if (map->debugfs) { |
523 | mutex_lock(&map->cache_lock); | 546 | debugfs_remove_recursive(map->debugfs); |
524 | regmap_debugfs_free_dump_cache(map); | 547 | mutex_lock(&map->cache_lock); |
525 | mutex_unlock(&map->cache_lock); | 548 | regmap_debugfs_free_dump_cache(map); |
526 | kfree(map->debugfs_name); | 549 | mutex_unlock(&map->cache_lock); |
550 | kfree(map->debugfs_name); | ||
551 | } else { | ||
552 | struct regmap_debugfs_node *node, *tmp; | ||
553 | |||
554 | mutex_lock(®map_debugfs_early_lock); | ||
555 | list_for_each_entry_safe(node, tmp, ®map_debugfs_early_list, | ||
556 | link) { | ||
557 | if (node->map == map) { | ||
558 | list_del(&node->link); | ||
559 | kfree(node); | ||
560 | } | ||
561 | } | ||
562 | mutex_unlock(®map_debugfs_early_lock); | ||
563 | } | ||
527 | } | 564 | } |
528 | 565 | ||
529 | void regmap_debugfs_initcall(void) | 566 | void regmap_debugfs_initcall(void) |
530 | { | 567 | { |
568 | struct regmap_debugfs_node *node, *tmp; | ||
569 | |||
531 | regmap_debugfs_root = debugfs_create_dir("regmap", NULL); | 570 | regmap_debugfs_root = debugfs_create_dir("regmap", NULL); |
532 | if (!regmap_debugfs_root) { | 571 | if (!regmap_debugfs_root) { |
533 | pr_warn("regmap: Failed to create debugfs root\n"); | 572 | pr_warn("regmap: Failed to create debugfs root\n"); |
534 | return; | 573 | return; |
535 | } | 574 | } |
575 | |||
576 | mutex_lock(®map_debugfs_early_lock); | ||
577 | list_for_each_entry_safe(node, tmp, ®map_debugfs_early_list, link) { | ||
578 | regmap_debugfs_init(node->map, node->name); | ||
579 | list_del(&node->link); | ||
580 | kfree(node); | ||
581 | } | ||
582 | mutex_unlock(®map_debugfs_early_lock); | ||
536 | } | 583 | } |