Commit c7dac7a9 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] mtd cleanup

	switched to devfs_remove(), killed gratitious devfs_handle_t arrays.
parent 94fa0261
...@@ -21,12 +21,7 @@ ...@@ -21,12 +21,7 @@
#define DEVICE_NR(device) (device) #define DEVICE_NR(device) (device)
#define LOCAL_END_REQUEST #define LOCAL_END_REQUEST
#include <linux/blk.h> #include <linux/blk.h>
#ifdef CONFIG_DEVFS_FS
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
static devfs_handle_t devfs_dir_handle = NULL;
static devfs_handle_t devfs_rw_handle[MAX_MTD_DEVICES];
#endif
static void mtd_notify_add(struct mtd_info* mtd); static void mtd_notify_add(struct mtd_info* mtd);
static void mtd_notify_remove(struct mtd_info* mtd); static void mtd_notify_remove(struct mtd_info* mtd);
...@@ -533,15 +528,15 @@ static struct block_device_operations mtd_fops = ...@@ -533,15 +528,15 @@ static struct block_device_operations mtd_fops =
static void mtd_notify_add(struct mtd_info* mtd) static void mtd_notify_add(struct mtd_info* mtd)
{ {
struct gendisk *disk; struct gendisk *disk;
char name[8]; char name[16];
if (!mtd || mtd->type == MTD_ABSENT) if (!mtd || mtd->type == MTD_ABSENT)
return; return;
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
sprintf(name, "%d", mtd->index); sprintf(name, DEVICE_NAME"/%d", mtd->index);
devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name, devfs_register(NULL, name, DEVFS_FL_DEFAULT,
DEVFS_FL_DEFAULT, MTD_BLOCK_MAJOR, mtd->index, MTD_BLOCK_MAJOR, mtd->index,
S_IFBLK | S_IRUGO | S_IWUGO, S_IFBLK | S_IRUGO | S_IWUGO,
&mtd_fops, NULL); &mtd_fops, NULL);
#endif #endif
...@@ -566,9 +561,7 @@ static void mtd_notify_remove(struct mtd_info* mtd) ...@@ -566,9 +561,7 @@ static void mtd_notify_remove(struct mtd_info* mtd)
if (!mtd || mtd->type == MTD_ABSENT) if (!mtd || mtd->type == MTD_ABSENT)
return; return;
#ifdef CONFIG_DEVFS_FS devfs_remove(DEVICE_NAME"/%d", mtd->index);
devfs_unregister(devfs_rw_handle[mtd->index]);
#endif
if (mtddisk[mtd->index]) { if (mtddisk[mtd->index]) {
del_gendisk(mtddisk[mtd->index]); del_gendisk(mtddisk[mtd->index]);
...@@ -588,7 +581,7 @@ int __init init_mtdblock(void) ...@@ -588,7 +581,7 @@ int __init init_mtdblock(void)
return -EAGAIN; return -EAGAIN;
} }
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
devfs_dir_handle = devfs_mk_dir(NULL, DEVICE_NAME, NULL); devfs_mk_dir(NULL, DEVICE_NAME, NULL);
#endif #endif
register_mtd_user(&notifier); register_mtd_user(&notifier);
...@@ -605,7 +598,7 @@ static void __exit cleanup_mtdblock(void) ...@@ -605,7 +598,7 @@ static void __exit cleanup_mtdblock(void)
down(&thread_sem); down(&thread_sem);
unregister_mtd_user(&notifier); unregister_mtd_user(&notifier);
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
devfs_unregister(devfs_dir_handle); devfs_remove(DEVICE_NAME);
#endif #endif
unregister_blkdev(MAJOR_NR,DEVICE_NAME); unregister_blkdev(MAJOR_NR,DEVICE_NAME);
blk_cleanup_queue(&mtd_queue); blk_cleanup_queue(&mtd_queue);
......
...@@ -23,9 +23,6 @@ static struct mtd_notifier notifier = { ...@@ -23,9 +23,6 @@ static struct mtd_notifier notifier = {
remove: mtd_notify_remove, remove: mtd_notify_remove,
}; };
static devfs_handle_t devfs_dir_handle;
static devfs_handle_t devfs_rw_handle[MAX_MTD_DEVICES];
static devfs_handle_t devfs_ro_handle[MAX_MTD_DEVICES];
#endif #endif
static loff_t mtd_lseek (struct file *file, loff_t offset, int orig) static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
...@@ -464,19 +461,19 @@ static struct file_operations mtd_fops = { ...@@ -464,19 +461,19 @@ static struct file_operations mtd_fops = {
static void mtd_notify_add(struct mtd_info* mtd) static void mtd_notify_add(struct mtd_info* mtd)
{ {
char name[8]; char name[16];
if (!mtd) if (!mtd)
return; return;
sprintf(name, "%d", mtd->index); sprintf(name, "mtd/%d", mtd->index);
devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name, devfs_register(NULL, name,
DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2, DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2,
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
&mtd_fops, NULL); &mtd_fops, NULL);
sprintf(name, "%dro", mtd->index); sprintf(name, "mtd/%dro", mtd->index);
devfs_ro_handle[mtd->index] = devfs_register(devfs_dir_handle, name, devfs_register(NULL, name,
DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2+1, DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2+1,
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
&mtd_fops, NULL); &mtd_fops, NULL);
...@@ -486,9 +483,8 @@ static void mtd_notify_remove(struct mtd_info* mtd) ...@@ -486,9 +483,8 @@ static void mtd_notify_remove(struct mtd_info* mtd)
{ {
if (!mtd) if (!mtd)
return; return;
devfs_remove("mtd/%d", mtd->index);
devfs_unregister(devfs_rw_handle[mtd->index]); devfs_remove("mtd/%dro", mtd->index);
devfs_unregister(devfs_ro_handle[mtd->index]);
} }
#endif #endif
...@@ -501,7 +497,7 @@ static int __init init_mtdchar(void) ...@@ -501,7 +497,7 @@ static int __init init_mtdchar(void)
} }
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
devfs_dir_handle = devfs_mk_dir(NULL, "mtd", NULL); devfs_mk_dir(NULL, "mtd", NULL);
register_mtd_user(&notifier); register_mtd_user(&notifier);
#endif #endif
...@@ -512,7 +508,7 @@ static void __exit cleanup_mtdchar(void) ...@@ -512,7 +508,7 @@ static void __exit cleanup_mtdchar(void)
{ {
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
unregister_mtd_user(&notifier); unregister_mtd_user(&notifier);
devfs_unregister(devfs_dir_handle); devfs_remove("mtd");
#endif #endif
unregister_chrdev(MTD_CHAR_MAJOR, "mtd"); unregister_chrdev(MTD_CHAR_MAJOR, "mtd");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment