Commit f68a4824 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] acorn floppy switched to alloc_disk()

parent 4d1fc631
...@@ -203,7 +203,7 @@ static struct archy_disk_type { ...@@ -203,7 +203,7 @@ static struct archy_disk_type {
*/ */
#define MAX_DISK_SIZE 720 #define MAX_DISK_SIZE 720
static struct gendisk disks[FD_MAX_UNIT]; static struct gendisk *disks[FD_MAX_UNIT];
/* current info on each unit */ /* current info on each unit */
static struct archy_floppy_struct { static struct archy_floppy_struct {
...@@ -961,7 +961,7 @@ static void fd_rwsec_done(int status) ...@@ -961,7 +961,7 @@ static void fd_rwsec_done(int status)
if (unit[SelectedDrive].disktype > disk_type) { if (unit[SelectedDrive].disktype > disk_type) {
/* try another disk type */ /* try another disk type */
unit[SelectedDrive].disktype--; unit[SelectedDrive].disktype--;
set_capacity(&disks[SelectedDrive], set_capacity(disks[SelectedDrive],
unit[SelectedDrive].disktype->blocks); unit[SelectedDrive].disktype->blocks);
} else } else
Probing = 0; Probing = 0;
...@@ -969,7 +969,7 @@ static void fd_rwsec_done(int status) ...@@ -969,7 +969,7 @@ static void fd_rwsec_done(int status)
/* record not found, but not probing. Maybe stretch wrong ? Restart probing */ /* record not found, but not probing. Maybe stretch wrong ? Restart probing */
if (unit[SelectedDrive].autoprobe) { if (unit[SelectedDrive].autoprobe) {
unit[SelectedDrive].disktype = disk_type + NUM_DISK_TYPES - 1; unit[SelectedDrive].disktype = disk_type + NUM_DISK_TYPES - 1;
set_capacity(&disks[SelectedDrive], set_capacity(disks[SelectedDrive],
unit[SelectedDrive].disktype->blocks); unit[SelectedDrive].disktype->blocks);
Probing = 1; Probing = 1;
} }
...@@ -1242,7 +1242,7 @@ static void redo_fd_request(void) ...@@ -1242,7 +1242,7 @@ static void redo_fd_request(void)
if (!floppy->disktype) { if (!floppy->disktype) {
Probing = 1; Probing = 1;
floppy->disktype = disk_type + NUM_DISK_TYPES - 1; floppy->disktype = disk_type + NUM_DISK_TYPES - 1;
set_capacity(&disks[drive], floppy->disktype->blocks); set_capacity(disks[drive], floppy->disktype->blocks);
floppy->autoprobe = 1; floppy->autoprobe = 1;
} }
} else { } else {
...@@ -1254,7 +1254,7 @@ static void redo_fd_request(void) ...@@ -1254,7 +1254,7 @@ static void redo_fd_request(void)
goto repeat; goto repeat;
} }
floppy->disktype = &disk_type[type]; floppy->disktype = &disk_type[type];
set_capacity(&disks[drive], floppy->disktype->blocks); set_capacity(disks[drive], floppy->disktype->blocks);
floppy->autoprobe = 0; floppy->autoprobe = 0;
} }
...@@ -1540,7 +1540,7 @@ static struct gendisk *floppy_find(int minor) ...@@ -1540,7 +1540,7 @@ static struct gendisk *floppy_find(int minor)
int drive = minor & 3; int drive = minor & 3;
if ((minor>> 2) > NUM_DISK_TYPES || drive >= FD_MAX_UNITS) if ((minor>> 2) > NUM_DISK_TYPES || drive >= FD_MAX_UNITS)
return NULL; return NULL;
return &disks[drive]; return disks[drive];
} }
int fd1772_init(void) int fd1772_init(void)
...@@ -1550,20 +1550,28 @@ int fd1772_init(void) ...@@ -1550,20 +1550,28 @@ int fd1772_init(void)
if (!machine_is_archimedes()) if (!machine_is_archimedes())
return 0; return 0;
for (i = 0; i < FD_MAX_UNITS; i++) {
disks[i] = alloc_disk();
if (!disks[i])
goto out;
}
if (register_blkdev(MAJOR_NR, "fd", &floppy_fops)) { if (register_blkdev(MAJOR_NR, "fd", &floppy_fops)) {
printk("Unable to get major %d for floppy\n", MAJOR_NR); printk("Unable to get major %d for floppy\n", MAJOR_NR);
return 1; goto out;
} }
if (request_dma(FLOPPY_DMA, "fd1772")) { if (request_dma(FLOPPY_DMA, "fd1772")) {
printk("Unable to grab DMA%d for the floppy (1772) driver\n", FLOPPY_DMA); printk("Unable to grab DMA%d for the floppy (1772) driver\n", FLOPPY_DMA);
return 1; unregister_blkdev(MAJOR_NR, "fd");
goto out;
}; };
if (request_dma(FIQ_FD1772, "fd1772 end")) { if (request_dma(FIQ_FD1772, "fd1772 end")) {
printk("Unable to grab DMA%d for the floppy (1772) driver\n", FIQ_FD1772); printk("Unable to grab DMA%d for the floppy (1772) driver\n", FIQ_FD1772);
unregister_blkdev(MAJOR_NR, "fd");
free_dma(FLOPPY_DMA); free_dma(FLOPPY_DMA);
return 1; goto out;
}; };
enable_dma(FIQ_FD1772); /* This inserts a call to our command end routine */ enable_dma(FIQ_FD1772); /* This inserts a call to our command end routine */
...@@ -1582,18 +1590,22 @@ int fd1772_init(void) ...@@ -1582,18 +1590,22 @@ int fd1772_init(void)
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_fd_request); blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_fd_request);
for (i = 0; i < FD_MAX_UNITS; i++) { for (i = 0; i < FD_MAX_UNITS; i++) {
unit[i].track = -1; unit[i].track = -1;
disks[i].major = MAJOR_NR; disks[i]->major = MAJOR_NR;
disks[i].first_minor = 0; disks[i]->first_minor = 0;
disks[i].fops = &floppy_fops; disks[i]->fops = &floppy_fops;
sprintf(disks[i].disk_name, "fd%d", i); sprintf(disks[i]->disk_name, "fd%d", i);
set_capacity(&disks[i], MAX_DISK_SIZE * 2); set_capacity(disks[i], MAX_DISK_SIZE * 2);
} }
blk_set_probe(MAJOR_NR, floppy_find); blk_set_probe(MAJOR_NR, floppy_find);
for (i = 0; i < FD_MAX_UNITS; i++) for (i = 0; i < FD_MAX_UNITS; i++)
add_disk(disks + i); add_disk(disks[i]);
config_types(); config_types();
return 0; return 0;
out:
while (i--)
put_disk(disks[i]);
return 1;
} }
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