diff options
Diffstat (limited to 'drivers/mtd/ubi/build.c')
-rw-r--r-- | drivers/mtd/ubi/build.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 5490a73deca5..44c852144a9c 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -67,6 +67,9 @@ struct ubi_device *ubi_devices[UBI_MAX_DEVICES]; | |||
67 | /* Root UBI "class" object (corresponds to '/<sysfs>/class/ubi/') */ | 67 | /* Root UBI "class" object (corresponds to '/<sysfs>/class/ubi/') */ |
68 | struct class *ubi_class; | 68 | struct class *ubi_class; |
69 | 69 | ||
70 | /* Slab cache for lock-tree entries */ | ||
71 | struct kmem_cache *ubi_ltree_slab; | ||
72 | |||
70 | /* "Show" method for files in '/<sysfs>/class/ubi/' */ | 73 | /* "Show" method for files in '/<sysfs>/class/ubi/' */ |
71 | static ssize_t ubi_version_show(struct class *class, char *buf) | 74 | static ssize_t ubi_version_show(struct class *class, char *buf) |
72 | { | 75 | { |
@@ -687,6 +690,20 @@ static void detach_mtd_dev(struct ubi_device *ubi) | |||
687 | ubi_msg("mtd%d is detached from ubi%d", mtd_num, ubi_num); | 690 | ubi_msg("mtd%d is detached from ubi%d", mtd_num, ubi_num); |
688 | } | 691 | } |
689 | 692 | ||
693 | /** | ||
694 | * ltree_entry_ctor - lock tree entries slab cache constructor. | ||
695 | * @obj: the lock-tree entry to construct | ||
696 | * @cache: the lock tree entry slab cache | ||
697 | * @flags: constructor flags | ||
698 | */ | ||
699 | static void ltree_entry_ctor(struct kmem_cache *cache, void *obj) | ||
700 | { | ||
701 | struct ubi_ltree_entry *le = obj; | ||
702 | |||
703 | le->users = 0; | ||
704 | init_rwsem(&le->mutex); | ||
705 | } | ||
706 | |||
690 | static int __init ubi_init(void) | 707 | static int __init ubi_init(void) |
691 | { | 708 | { |
692 | int err, i, k; | 709 | int err, i, k; |
@@ -709,6 +726,12 @@ static int __init ubi_init(void) | |||
709 | if (err) | 726 | if (err) |
710 | goto out_class; | 727 | goto out_class; |
711 | 728 | ||
729 | ubi_ltree_slab = kmem_cache_create("ubi_ltree_slab", | ||
730 | sizeof(struct ubi_ltree_entry), 0, | ||
731 | 0, <ree_entry_ctor); | ||
732 | if (!ubi_ltree_slab) | ||
733 | goto out_version; | ||
734 | |||
712 | /* Attach MTD devices */ | 735 | /* Attach MTD devices */ |
713 | for (i = 0; i < mtd_devs; i++) { | 736 | for (i = 0; i < mtd_devs; i++) { |
714 | struct mtd_dev_param *p = &mtd_dev_param[i]; | 737 | struct mtd_dev_param *p = &mtd_dev_param[i]; |
@@ -724,6 +747,8 @@ static int __init ubi_init(void) | |||
724 | out_detach: | 747 | out_detach: |
725 | for (k = 0; k < i; k++) | 748 | for (k = 0; k < i; k++) |
726 | detach_mtd_dev(ubi_devices[k]); | 749 | detach_mtd_dev(ubi_devices[k]); |
750 | kmem_cache_destroy(ubi_ltree_slab); | ||
751 | out_version: | ||
727 | class_remove_file(ubi_class, &ubi_version); | 752 | class_remove_file(ubi_class, &ubi_version); |
728 | out_class: | 753 | out_class: |
729 | class_destroy(ubi_class); | 754 | class_destroy(ubi_class); |
@@ -737,6 +762,7 @@ static void __exit ubi_exit(void) | |||
737 | 762 | ||
738 | for (i = 0; i < n; i++) | 763 | for (i = 0; i < n; i++) |
739 | detach_mtd_dev(ubi_devices[i]); | 764 | detach_mtd_dev(ubi_devices[i]); |
765 | kmem_cache_destroy(ubi_ltree_slab); | ||
740 | class_remove_file(ubi_class, &ubi_version); | 766 | class_remove_file(ubi_class, &ubi_version); |
741 | class_destroy(ubi_class); | 767 | class_destroy(ubi_class); |
742 | } | 768 | } |