Commit 9d129a7b authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] amiga floppy

	* switched to private queue
	* set ->queue and ->private_data
	* switched to new methods
parent d74a3894
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
#define MAJOR_NR FLOPPY_MAJOR #define MAJOR_NR FLOPPY_MAJOR
#define DEVICE_NAME "floppy" #define DEVICE_NAME "floppy"
#define DEVICE_NR(device) ( (minor(device) & 3) | ((minor(device) & 0x80 ) >> 5 )) #define QUEUE (&floppy_queue)
#include <linux/blk.h> #include <linux/blk.h>
#undef DEBUG /* print _LOTS_ of infos */ #undef DEBUG /* print _LOTS_ of infos */
...@@ -123,6 +123,8 @@ static long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't ident ...@@ -123,6 +123,8 @@ static long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't ident
MODULE_PARM(fd_def_df0,"l"); MODULE_PARM(fd_def_df0,"l");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static struct request_queue floppy_queue;
/* /*
* Macros * Macros
*/ */
...@@ -1377,14 +1379,10 @@ static void redo_fd_request(void) ...@@ -1377,14 +1379,10 @@ static void redo_fd_request(void)
return; return;
} }
if (major(CURRENT->rq_dev) != MAJOR_NR)
panic(DEVICE_NAME ": request list destroyed");
device = minor(CURRENT->rq_dev); device = minor(CURRENT->rq_dev);
if (device < 8) { if (device < 8) {
/* manual selection */ /* manual selection */
drive = device & 3; drive = device & 3;
floppy = unit + drive;
} else { } else {
/* Auto-detection */ /* Auto-detection */
#ifdef DEBUG #ifdef DEBUG
...@@ -1392,8 +1390,8 @@ static void redo_fd_request(void) ...@@ -1392,8 +1390,8 @@ static void redo_fd_request(void)
printk("redo_fd_request: default to normal\n"); printk("redo_fd_request: default to normal\n");
#endif #endif
drive = device & 3; drive = device & 3;
floppy = unit + drive;
} }
floppy = CURRENT->rq_disk->private_data;
/* Here someone could investigate to be more efficient */ /* Here someone could investigate to be more efficient */
for (cnt = 0; cnt < CURRENT->current_nr_sectors; cnt++) { for (cnt = 0; cnt < CURRENT->current_nr_sectors; cnt++) {
...@@ -1428,11 +1426,11 @@ static void redo_fd_request(void) ...@@ -1428,11 +1426,11 @@ static void redo_fd_request(void)
switch (rq_data_dir(CURRENT)) { switch (rq_data_dir(CURRENT)) {
case READ: case READ:
memcpy(data, unit[drive].trackbuf + sector * 512, 512); memcpy(data, floppy->trackbuf + sector * 512, 512);
break; break;
case WRITE: case WRITE:
memcpy(unit[drive].trackbuf + sector * 512, data, 512); memcpy(floppy->trackbuf + sector * 512, data, 512);
/* keep the drive spinning while writes are scheduled */ /* keep the drive spinning while writes are scheduled */
if (!fd_motor_on(drive)) { if (!fd_motor_on(drive)) {
...@@ -1446,7 +1444,7 @@ static void redo_fd_request(void) ...@@ -1446,7 +1444,7 @@ static void redo_fd_request(void)
save_flags (flags); save_flags (flags);
cli(); cli();
unit[drive].dirty = 1; floppy->dirty = 1;
/* reset the timer */ /* reset the timer */
del_timer (flush_track_timer + drive); del_timer (flush_track_timer + drive);
...@@ -1674,9 +1672,10 @@ static int floppy_release(struct inode * inode, struct file * filp) ...@@ -1674,9 +1672,10 @@ static int floppy_release(struct inode * inode, struct file * filp)
* to the desired drive, but it will probably not survive the sleep if * to the desired drive, but it will probably not survive the sleep if
* several floppies are used at the same time: thus the loop. * several floppies are used at the same time: thus the loop.
*/ */
static int amiga_floppy_change(kdev_t dev) static int amiga_floppy_change(struct gendisk *disk)
{ {
int drive = minor(dev) & 3; struct amiga_floppy_struct *p = disk->private_data;
int drive = p - unit;
int changed; int changed;
static int first_time = 1; static int first_time = 1;
...@@ -1692,8 +1691,8 @@ static int amiga_floppy_change(kdev_t dev) ...@@ -1692,8 +1691,8 @@ static int amiga_floppy_change(kdev_t dev)
if (changed) { if (changed) {
fd_probe(drive); fd_probe(drive);
unit[drive].track = -1; p->track = -1;
unit[drive].dirty = 0; p->dirty = 0;
writepending = 0; /* if this was true before, too bad! */ writepending = 0; /* if this was true before, too bad! */
writefromint = 0; writefromint = 0;
return 1; return 1;
...@@ -1702,11 +1701,11 @@ static int amiga_floppy_change(kdev_t dev) ...@@ -1702,11 +1701,11 @@ static int amiga_floppy_change(kdev_t dev)
} }
static struct block_device_operations floppy_fops = { static struct block_device_operations floppy_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = floppy_open, .open = floppy_open,
.release = floppy_release, .release = floppy_release,
.ioctl = fd_ioctl, .ioctl = fd_ioctl,
.check_media_change = amiga_floppy_change, .media_changed = amiga_floppy_change,
}; };
void __init amiga_floppy_setup (char *str, int *ints) void __init amiga_floppy_setup (char *str, int *ints)
...@@ -1745,6 +1744,8 @@ static int __init fd_probe_drives(void) ...@@ -1745,6 +1744,8 @@ static int __init fd_probe_drives(void)
disk->first_minor = drive; disk->first_minor = drive;
disk->fops = &floppy_fops; disk->fops = &floppy_fops;
sprintf(disk->disk_name, "fd%d", drive); sprintf(disk->disk_name, "fd%d", drive);
disk->private_data = &unit[drive];
disk->queue = &floppy_queue;
set_capacity(disk, 880*2); set_capacity(disk, 880*2);
add_disk(disk); add_disk(disk);
} }
...@@ -1842,7 +1843,7 @@ int __init amiga_floppy_init(void) ...@@ -1842,7 +1843,7 @@ int __init amiga_floppy_init(void)
post_write_timer.data = 0; post_write_timer.data = 0;
post_write_timer.function = post_write; post_write_timer.function = post_write;
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_fd_request, &amiflop_lock); blk_init_queue(&floppy_queue, do_fd_request, &amiflop_lock);
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++)
mfmdecode[i]=255; mfmdecode[i]=255;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
...@@ -1882,7 +1883,7 @@ void cleanup_module(void) ...@@ -1882,7 +1883,7 @@ void cleanup_module(void)
free_irq(IRQ_AMIGA_DSKBLK, NULL); free_irq(IRQ_AMIGA_DSKBLK, NULL);
custom.dmacon = DMAF_DISK; /* disable DMA */ custom.dmacon = DMAF_DISK; /* disable DMA */
amiga_chip_free(raw_buf); amiga_chip_free(raw_buf);
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blk_cleanup_queue(&floppy_queue);
release_mem_region(CUSTOM_PHYSADDR+0x20, 8); release_mem_region(CUSTOM_PHYSADDR+0x20, 8);
unregister_blkdev(MAJOR_NR, "fd"); unregister_blkdev(MAJOR_NR, "fd");
} }
......
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