Commit 26f6deaa authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] swim* switched to alloc_disk()

parent b6b51807
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
static struct gendisk disks[2]; static struct gendisk *disks[2];
#define MAX_FLOPPIES 2 #define MAX_FLOPPIES 2
...@@ -1014,6 +1014,7 @@ static devfs_handle_t floppy_devfs_handle; ...@@ -1014,6 +1014,7 @@ static devfs_handle_t floppy_devfs_handle;
int swim3_init(void) int swim3_init(void)
{ {
struct device_node *swim; struct device_node *swim;
int err = -ENOMEM;
int i; int i;
floppy_devfs_handle = devfs_mk_dir(NULL, "floppy", NULL); floppy_devfs_handle = devfs_mk_dir(NULL, "floppy", NULL);
...@@ -1032,26 +1033,37 @@ int swim3_init(void) ...@@ -1032,26 +1033,37 @@ int swim3_init(void)
swim = swim->next; swim = swim->next;
} }
if (floppy_count > 0) if (!floppy_count)
{ return -ENODEV;
if (register_blkdev(MAJOR_NR, "fd", &floppy_fops)) {
printk(KERN_ERR "Unable to get major %d for floppy\n", for (i = 0; i < floppy_count; i++) {
MAJOR_NR); disks[i] = alloc_disk();
return -EBUSY; if (!disks[i])
} goto out;
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_fd_request, &swim3_lock);
for (i = 0; i < floppy_count; i++) {
struct gendisk *disk = disks + i;
disk->major = MAJOR_NR;
disk->first_minor = i;
disk->fops = &floppy_fops;
sprintf(disk->disk_name, "fd%d", i);
set_capacity(disk, 2880);
add_disk(disk);
}
} }
if (register_blkdev(MAJOR_NR, "fd", &floppy_fops)) {
printk(KERN_ERR"Unable to get major %d for floppy\n", MAJOR_NR);
err = -EBUSY;
goto out;
}
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_fd_request, &swim3_lock);
for (i = 0; i < floppy_count; i++) {
struct gendisk *disk = disks[i];
disk->major = MAJOR_NR;
disk->first_minor = i;
disk->fops = &floppy_fops;
sprintf(disk->disk_name, "fd%d", i);
set_capacity(disk, 2880);
add_disk(disk);
}
return 0; return 0;
out:
while (i--)
put_disk(disks[i]);
/* shouldn't we do something with results of swim_add_device()? */
return err;
} }
static int swim3_add_device(struct device_node *swim) static int swim3_add_device(struct device_node *swim)
...@@ -1118,8 +1130,6 @@ static int swim3_add_device(struct device_node *swim) ...@@ -1118,8 +1130,6 @@ static int swim3_add_device(struct device_node *swim)
init_timer(&fs->timeout); init_timer(&fs->timeout);
do_floppy = NULL;
printk(KERN_INFO "fd%d: SWIM3 floppy controller %s\n", floppy_count, printk(KERN_INFO "fd%d: SWIM3 floppy controller %s\n", floppy_count,
mediabay ? "in media bay" : ""); mediabay ? "in media bay" : "");
sprintf(floppy_name, "%s%d", floppy_devfs_handle ? "" : "floppy", sprintf(floppy_name, "%s%d", floppy_devfs_handle ? "" : "floppy",
......
...@@ -82,9 +82,6 @@ static struct swim_iop_req *current_req; ...@@ -82,9 +82,6 @@ static struct swim_iop_req *current_req;
static int floppy_count; static int floppy_count;
static struct floppy_state floppy_states[MAX_FLOPPIES]; static struct floppy_state floppy_states[MAX_FLOPPIES];
static struct gendisk disks[2];
static spinlock_t swim_iop_lock = SPIN_LOCK_UNLOCKED; static spinlock_t swim_iop_lock = SPIN_LOCK_UNLOCKED;
static char *drive_names[7] = { static char *drive_names[7] = {
...@@ -190,9 +187,10 @@ int swimiop_init(void) ...@@ -190,9 +187,10 @@ int swimiop_init(void)
} }
printk("SWIM-IOP: detected %d installed drives.\n", floppy_count); printk("SWIM-IOP: detected %d installed drives.\n", floppy_count);
do_floppy = NULL;
for (i = 0; i < floppy_count; i++) { for (i = 0; i < floppy_count; i++) {
struct gendisk *disk = disks + i; struct gendisk *disk = alloc_disk();
if (!disk)
continue;
disk->major = MAJOR_NR; disk->major = MAJOR_NR;
disk->first_minor = i; disk->first_minor = i;
disk->fops = &floppy_fops; disk->fops = &floppy_fops;
......
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