Commit 4d1fc631 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] amiga floppy switched to alloc_disk()

parent 0309add5
...@@ -1643,7 +1643,7 @@ static int floppy_open(struct inode *inode, struct file *filp) ...@@ -1643,7 +1643,7 @@ static int floppy_open(struct inode *inode, struct file *filp)
unit[drive].dtype=&data_types[system]; unit[drive].dtype=&data_types[system];
unit[drive].blocks=unit[drive].type->heads*unit[drive].type->tracks* unit[drive].blocks=unit[drive].type->heads*unit[drive].type->tracks*
data_types[system].sects*unit[drive].type->sect_mult; data_types[system].sects*unit[drive].type->sect_mult;
set_capacity(&unit[drive].disk, unit[drive].blocks); set_capacity(unit[drive].gendisk, unit[drive].blocks);
printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive,
unit[drive].type->name, data_types[system].name); unit[drive].type->name, data_types[system].name);
...@@ -1731,25 +1731,31 @@ static int __init fd_probe_drives(void) ...@@ -1731,25 +1731,31 @@ static int __init fd_probe_drives(void)
drives=0; drives=0;
nomem=0; nomem=0;
for(drive=0;drive<FD_MAX_UNITS;drive++) { for(drive=0;drive<FD_MAX_UNITS;drive++) {
struct gendisk *disk;
fd_probe(drive); fd_probe(drive);
if (unit[drive].type->code != FD_NODRIVE) { if (unit[drive].type->code == FD_NODRIVE)
struct gendisk *disk = &unit[drive].disk; continue;
drives++; disk = alloc_disk();
if ((unit[drive].trackbuf = kmalloc(FLOPPY_MAX_SECTORS * 512, GFP_KERNEL)) == NULL) { if (!disk) {
printk("no mem for "); unit[drive].type->code = FD_NODRIVE;
unit[drive].type = &drive_types[num_dr_types - 1]; /* FD_NODRIVE */ continue;
drives--; }
nomem = 1; unit[drive].gendisk = disk;
} drives++;
printk("fd%d ",drive); if ((unit[drive].trackbuf = kmalloc(FLOPPY_MAX_SECTORS * 512, GFP_KERNEL)) == NULL) {
disk->major = MAJOR_NR; printk("no mem for ");
disk->first_minor = drive; unit[drive].type = &drive_types[num_dr_types - 1]; /* FD_NODRIVE */
disk->minor_shift = 0; drives--;
disk->fops = &floppy_fops; nomem = 1;
sprintf(disk->disk_name, "fd%d", drive);
set_capacity(disk, 880*2);
add_disk(disk);
} }
printk("fd%d ",drive);
disk->major = MAJOR_NR;
disk->first_minor = drive;
disk->minor_shift = 0;
disk->fops = &floppy_fops;
sprintf(disk->disk_name, "fd%d", drive);
set_capacity(disk, 880*2);
add_disk(disk);
} }
if ((drives > 0) || (nomem == 0)) { if ((drives > 0) || (nomem == 0)) {
if (drives == 0) if (drives == 0)
...@@ -1766,7 +1772,7 @@ static struct gendisk *floppy_find(int minor) ...@@ -1766,7 +1772,7 @@ static struct gendisk *floppy_find(int minor)
int drive = minor & 3; int drive = minor & 3;
if (unit[drive].type->code == FD_NODRIVE) if (unit[drive].type->code == FD_NODRIVE)
return NULL; return NULL;
return &unit[drive].disk; return unit[drive].gendisk;
} }
int __init amiga_floppy_init(void) int __init amiga_floppy_init(void)
...@@ -1875,7 +1881,8 @@ void cleanup_module(void) ...@@ -1875,7 +1881,8 @@ void cleanup_module(void)
for( i = 0; i < FD_MAX_UNITS; i++) { for( i = 0; i < FD_MAX_UNITS; i++) {
if (unit[i].type->code != FD_NODRIVE) { if (unit[i].type->code != FD_NODRIVE) {
del_gendisk(&unit[i].disk); del_gendisk(unit[i].gendisk);
put_disk(unit[i].gendisk);
kfree(unit[i].trackbuf); kfree(unit[i].trackbuf);
} }
} }
......
...@@ -55,7 +55,7 @@ struct amiga_floppy_struct { ...@@ -55,7 +55,7 @@ struct amiga_floppy_struct {
int busy; /* true when drive is active */ int busy; /* true when drive is active */
int dirty; /* true when trackbuf is not on disk */ int dirty; /* true when trackbuf is not on disk */
int status; /* current error code for unit */ int status; /* current error code for unit */
struct gendisk disk; struct gendisk *gendisk;
}; };
#endif #endif
......
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