diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-16 05:49:01 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-26 12:15:14 -0500 |
commit | 06b68ba15671f32a3aa3bbddf04b0d2dd7fbf902 (patch) | |
tree | 67024857173069023835148077775e8c9e381d8a /drivers/mtd/ubi/build.c | |
parent | 3a8d4642861fb69b62401949e490c0bcb19ceb40 (diff) |
UBI: create ubi_wl_entry slab on initialization
Similarly to ltree_entry_slab, it makes more sense to create
and destroy ubi_wl_entry slab on module initialization/exit.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/build.c')
-rw-r--r-- | drivers/mtd/ubi/build.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 44c852144a9c..7f6820becf10 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -70,6 +70,10 @@ struct class *ubi_class; | |||
70 | /* Slab cache for lock-tree entries */ | 70 | /* Slab cache for lock-tree entries */ |
71 | struct kmem_cache *ubi_ltree_slab; | 71 | struct kmem_cache *ubi_ltree_slab; |
72 | 72 | ||
73 | /* Slab cache for wear-leveling entries */ | ||
74 | struct kmem_cache *ubi_wl_entry_slab; | ||
75 | |||
76 | |||
73 | /* "Show" method for files in '/<sysfs>/class/ubi/' */ | 77 | /* "Show" method for files in '/<sysfs>/class/ubi/' */ |
74 | static ssize_t ubi_version_show(struct class *class, char *buf) | 78 | static ssize_t ubi_version_show(struct class *class, char *buf) |
75 | { | 79 | { |
@@ -732,6 +736,12 @@ static int __init ubi_init(void) | |||
732 | if (!ubi_ltree_slab) | 736 | if (!ubi_ltree_slab) |
733 | goto out_version; | 737 | goto out_version; |
734 | 738 | ||
739 | ubi_wl_entry_slab = kmem_cache_create("ubi_wl_entry_slab", | ||
740 | sizeof(struct ubi_wl_entry), | ||
741 | 0, 0, NULL); | ||
742 | if (!ubi_wl_entry_slab) | ||
743 | goto out_ltree; | ||
744 | |||
735 | /* Attach MTD devices */ | 745 | /* Attach MTD devices */ |
736 | for (i = 0; i < mtd_devs; i++) { | 746 | for (i = 0; i < mtd_devs; i++) { |
737 | struct mtd_dev_param *p = &mtd_dev_param[i]; | 747 | struct mtd_dev_param *p = &mtd_dev_param[i]; |
@@ -747,6 +757,8 @@ static int __init ubi_init(void) | |||
747 | out_detach: | 757 | out_detach: |
748 | for (k = 0; k < i; k++) | 758 | for (k = 0; k < i; k++) |
749 | detach_mtd_dev(ubi_devices[k]); | 759 | detach_mtd_dev(ubi_devices[k]); |
760 | kmem_cache_destroy(ubi_wl_entry_slab); | ||
761 | out_ltree: | ||
750 | kmem_cache_destroy(ubi_ltree_slab); | 762 | kmem_cache_destroy(ubi_ltree_slab); |
751 | out_version: | 763 | out_version: |
752 | class_remove_file(ubi_class, &ubi_version); | 764 | class_remove_file(ubi_class, &ubi_version); |
@@ -762,6 +774,7 @@ static void __exit ubi_exit(void) | |||
762 | 774 | ||
763 | for (i = 0; i < n; i++) | 775 | for (i = 0; i < n; i++) |
764 | detach_mtd_dev(ubi_devices[i]); | 776 | detach_mtd_dev(ubi_devices[i]); |
777 | kmem_cache_destroy(ubi_wl_entry_slab); | ||
765 | kmem_cache_destroy(ubi_ltree_slab); | 778 | kmem_cache_destroy(ubi_ltree_slab); |
766 | class_remove_file(ubi_class, &ubi_version); | 779 | class_remove_file(ubi_class, &ubi_version); |
767 | class_destroy(ubi_class); | 780 | class_destroy(ubi_class); |