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 @@
#define DEVICE_NR(device) (device)
#define LOCAL_END_REQUEST
#include <linux/blk.h>
#ifdef CONFIG_DEVFS_FS
#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_remove(struct mtd_info* mtd);
......@@ -533,15 +528,15 @@ static struct block_device_operations mtd_fops =
static void mtd_notify_add(struct mtd_info* mtd)
{
struct gendisk *disk;
char name[8];
char name[16];
if (!mtd || mtd->type == MTD_ABSENT)
return;
#ifdef CONFIG_DEVFS_FS
sprintf(name, "%d", mtd->index);
devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name,
DEVFS_FL_DEFAULT, MTD_BLOCK_MAJOR, mtd->index,
sprintf(name, DEVICE_NAME"/%d", mtd->index);
devfs_register(NULL, name, DEVFS_FL_DEFAULT,
MTD_BLOCK_MAJOR, mtd->index,
S_IFBLK | S_IRUGO | S_IWUGO,
&mtd_fops, NULL);
#endif
......@@ -566,9 +561,7 @@ static void mtd_notify_remove(struct mtd_info* mtd)
if (!mtd || mtd->type == MTD_ABSENT)
return;
#ifdef CONFIG_DEVFS_FS
devfs_unregister(devfs_rw_handle[mtd->index]);
#endif
devfs_remove(DEVICE_NAME"/%d", mtd->index);
if (mtddisk[mtd->index]) {
del_gendisk(mtddisk[mtd->index]);
......@@ -588,7 +581,7 @@ int __init init_mtdblock(void)
return -EAGAIN;
}
#ifdef CONFIG_DEVFS_FS
devfs_dir_handle = devfs_mk_dir(NULL, DEVICE_NAME, NULL);
devfs_mk_dir(NULL, DEVICE_NAME, NULL);
#endif
register_mtd_user(&notifier);
......@@ -605,7 +598,7 @@ static void __exit cleanup_mtdblock(void)
down(&thread_sem);
unregister_mtd_user(&notifier);
#ifdef CONFIG_DEVFS_FS
devfs_unregister(devfs_dir_handle);
devfs_remove(DEVICE_NAME);
#endif
unregister_blkdev(MAJOR_NR,DEVICE_NAME);
blk_cleanup_queue(&mtd_queue);
......
......@@ -23,9 +23,6 @@ static struct mtd_notifier notifier = {
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
static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
......@@ -464,19 +461,19 @@ static struct file_operations mtd_fops = {
static void mtd_notify_add(struct mtd_info* mtd)
{
char name[8];
char name[16];
if (!mtd)
return;
sprintf(name, "%d", mtd->index);
devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name,
sprintf(name, "mtd/%d", mtd->index);
devfs_register(NULL, name,
DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2,
S_IFCHR | S_IRUGO | S_IWUGO,
&mtd_fops, NULL);
sprintf(name, "%dro", mtd->index);
devfs_ro_handle[mtd->index] = devfs_register(devfs_dir_handle, name,
sprintf(name, "mtd/%dro", mtd->index);
devfs_register(NULL, name,
DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2+1,
S_IFCHR | S_IRUGO | S_IWUGO,
&mtd_fops, NULL);
......@@ -486,9 +483,8 @@ static void mtd_notify_remove(struct mtd_info* mtd)
{
if (!mtd)
return;
devfs_unregister(devfs_rw_handle[mtd->index]);
devfs_unregister(devfs_ro_handle[mtd->index]);
devfs_remove("mtd/%d", mtd->index);
devfs_remove("mtd/%dro", mtd->index);
}
#endif
......@@ -501,7 +497,7 @@ static int __init init_mtdchar(void)
}
#ifdef CONFIG_DEVFS_FS
devfs_dir_handle = devfs_mk_dir(NULL, "mtd", NULL);
devfs_mk_dir(NULL, "mtd", NULL);
register_mtd_user(&notifier);
#endif
......@@ -512,7 +508,7 @@ static void __exit cleanup_mtdchar(void)
{
#ifdef CONFIG_DEVFS_FS
unregister_mtd_user(&notifier);
devfs_unregister(devfs_dir_handle);
devfs_remove("mtd");
#endif
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