Commit 94fa0261 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] nbd.c cleanup

	switched to explicit devfs_register()/devfs_remove()
parent f9614209
......@@ -59,7 +59,6 @@
#define LO_MAGIC 0x68797548
static struct nbd_device nbd_dev[MAX_NBD];
static devfs_handle_t devfs_handle;
static spinlock_t nbd_lock = SPIN_LOCK_UNLOCKED;
......@@ -549,8 +548,10 @@ static int __init nbd_init(void)
printk("nbd: registered device at major %d\n", MAJOR_NR);
#endif
blk_init_queue(&nbd_queue, do_nbd_request, &nbd_lock);
devfs_mk_dir (NULL, "nbd", NULL);
for (i = 0; i < MAX_NBD; i++) {
struct gendisk *disk = nbd_dev[i].disk;
char name[16];
nbd_dev[i].refcnt = 0;
nbd_dev[i].file = NULL;
nbd_dev[i].magic = LO_MAGIC;
......@@ -568,12 +569,12 @@ static int __init nbd_init(void)
sprintf(disk->disk_name, "nbd%d", i);
set_capacity(disk, 0x3ffffe);
add_disk(disk);
}
devfs_handle = devfs_mk_dir (NULL, "nbd", NULL);
devfs_register_series (devfs_handle, "%u", MAX_NBD,
DEVFS_FL_DEFAULT, MAJOR_NR, 0,
sprintf(name, "nbd/%d", i);
devfs_register(NULL, name, DEVFS_FL_DEFAULT,
disk->major, disk->first_minor,
S_IFBLK | S_IRUSR | S_IWUSR,
&nbd_fops, NULL);
disk->fops, NULL);
}
return 0;
out:
......@@ -588,14 +589,11 @@ static void __exit nbd_cleanup(void)
for (i = 0; i < MAX_NBD; i++) {
del_gendisk(nbd_dev[i].disk);
put_disk(nbd_dev[i].disk);
devfs_remove("nbd/%d", i);
}
devfs_unregister (devfs_handle);
devfs_remove("nbd");
blk_cleanup_queue(&nbd_queue);
if (unregister_blkdev(MAJOR_NR, "nbd") != 0)
printk("nbd: cleanup_module failed\n");
else
printk("nbd: module cleaned up.\n");
unregister_blkdev(MAJOR_NR, "nbd");
}
module_init(nbd_init);
......
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