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