diff options
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r-- | drivers/mtd/mtdchar.c | 47 |
1 files changed, 6 insertions, 41 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index f478f1fc3949..763d3f0a1f42 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -20,33 +20,6 @@ | |||
20 | 20 | ||
21 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
22 | 22 | ||
23 | static struct class *mtd_class; | ||
24 | |||
25 | static void mtd_notify_add(struct mtd_info* mtd) | ||
26 | { | ||
27 | if (!mtd) | ||
28 | return; | ||
29 | |||
30 | device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), | ||
31 | NULL, "mtd%d", mtd->index); | ||
32 | |||
33 | device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), | ||
34 | NULL, "mtd%dro", mtd->index); | ||
35 | } | ||
36 | |||
37 | static void mtd_notify_remove(struct mtd_info* mtd) | ||
38 | { | ||
39 | if (!mtd) | ||
40 | return; | ||
41 | |||
42 | device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2)); | ||
43 | device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1)); | ||
44 | } | ||
45 | |||
46 | static struct mtd_notifier notifier = { | ||
47 | .add = mtd_notify_add, | ||
48 | .remove = mtd_notify_remove, | ||
49 | }; | ||
50 | 23 | ||
51 | /* | 24 | /* |
52 | * Data structure to hold the pointer to the mtd device as well | 25 | * Data structure to hold the pointer to the mtd device as well |
@@ -854,34 +827,26 @@ static const struct file_operations mtd_fops = { | |||
854 | 827 | ||
855 | static int __init init_mtdchar(void) | 828 | static int __init init_mtdchar(void) |
856 | { | 829 | { |
857 | if (register_chrdev(MTD_CHAR_MAJOR, "mtd", &mtd_fops)) { | 830 | int status; |
831 | |||
832 | status = register_chrdev(MTD_CHAR_MAJOR, "mtd", &mtd_fops); | ||
833 | if (status < 0) { | ||
858 | printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n", | 834 | printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n", |
859 | MTD_CHAR_MAJOR); | 835 | MTD_CHAR_MAJOR); |
860 | return -EAGAIN; | ||
861 | } | ||
862 | |||
863 | mtd_class = class_create(THIS_MODULE, "mtd"); | ||
864 | |||
865 | if (IS_ERR(mtd_class)) { | ||
866 | printk(KERN_ERR "Error creating mtd class.\n"); | ||
867 | unregister_chrdev(MTD_CHAR_MAJOR, "mtd"); | ||
868 | return PTR_ERR(mtd_class); | ||
869 | } | 836 | } |
870 | 837 | ||
871 | register_mtd_user(¬ifier); | 838 | return status; |
872 | return 0; | ||
873 | } | 839 | } |
874 | 840 | ||
875 | static void __exit cleanup_mtdchar(void) | 841 | static void __exit cleanup_mtdchar(void) |
876 | { | 842 | { |
877 | unregister_mtd_user(¬ifier); | ||
878 | class_destroy(mtd_class); | ||
879 | unregister_chrdev(MTD_CHAR_MAJOR, "mtd"); | 843 | unregister_chrdev(MTD_CHAR_MAJOR, "mtd"); |
880 | } | 844 | } |
881 | 845 | ||
882 | module_init(init_mtdchar); | 846 | module_init(init_mtdchar); |
883 | module_exit(cleanup_mtdchar); | 847 | module_exit(cleanup_mtdchar); |
884 | 848 | ||
849 | MODULE_ALIAS_CHARDEV_MAJOR(MTD_CHAR_MAJOR); | ||
885 | 850 | ||
886 | MODULE_LICENSE("GPL"); | 851 | MODULE_LICENSE("GPL"); |
887 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); | 852 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); |