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

[PATCH] acorn floppy

	* switched to private queue
	* set ->queue and ->private_data
	* switched to new methods
	* compile fixes

NOTE: it still has b0rken locking - hadn't been updated in 2.5.1
parent a7fb3d08
...@@ -156,6 +156,7 @@ ...@@ -156,6 +156,7 @@
#define FLOPPY_DMA 0 #define FLOPPY_DMA 0
#define DEVICE_NAME "floppy" #define DEVICE_NAME "floppy"
#define DEVICE_NR(device) ( (minor(device) & 3) | ((minor(device) & 0x80 ) >> 5 )) #define DEVICE_NR(device) ( (minor(device) & 3) | ((minor(device) & 0x80 ) >> 5 ))
#define QUEUE (&floppy_queue)
#include <linux/blk.h> #include <linux/blk.h>
/* Note: FD_MAX_UNITS could be redefined to 2 for the Atari (with /* Note: FD_MAX_UNITS could be redefined to 2 for the Atari (with
...@@ -179,6 +180,8 @@ ...@@ -179,6 +180,8 @@
#define DPRINT(a) #define DPRINT(a)
#endif #endif
static struct request_queue floppy_queue;
/* Disk types: DD */ /* Disk types: DD */
static struct archy_disk_type { static struct archy_disk_type {
const char *name; const char *name;
...@@ -1140,14 +1143,11 @@ static void floppy_off(unsigned int nr) ...@@ -1140,14 +1143,11 @@ static void floppy_off(unsigned int nr)
- but if it sees a disc change line go high (?) it flips to using - but if it sees a disc change line go high (?) it flips to using
it. Well maybe I'll add that in the future (!?) it. Well maybe I'll add that in the future (!?)
*/ */
static int check_floppy_change(dev_t dev) static int check_floppy_change(struct gendisk *disk)
{ {
unsigned int drive = (dev & 0x03); struct archy_floppy_struct *p = disk->private_data;
unsigned int drive = p - unit;
if (major(dev) != MAJOR_NR) {
printk("floppy_changed: not a floppy\n");
return 0;
}
if (test_bit(drive, &fake_change)) { if (test_bit(drive, &fake_change)) {
/* simulated change (e.g. after formatting) */ /* simulated change (e.g. after formatting) */
return 1; return 1;
...@@ -1156,7 +1156,7 @@ static int check_floppy_change(dev_t dev) ...@@ -1156,7 +1156,7 @@ static int check_floppy_change(dev_t dev)
/* surely changed (the WP signal changed at least once) */ /* surely changed (the WP signal changed at least once) */
return 1; return 1;
} }
if (unit[drive].wpstat) { if (p->wpstat) {
/* WP is on -> could be changed: to be sure, buffers should be /* WP is on -> could be changed: to be sure, buffers should be
* invalidated... * invalidated...
*/ */
...@@ -1165,9 +1165,10 @@ static int check_floppy_change(dev_t dev) ...@@ -1165,9 +1165,10 @@ static int check_floppy_change(dev_t dev)
return 1; /* DAG - was 0 */ return 1; /* DAG - was 0 */
} }
static int floppy_revalidate(dev_t dev) static int floppy_revalidate(struct gendisk *disk)
{ {
int drive = dev & 3; struct archy_floppy_struct *p = disk->private_data;
unsigned int drive = p - unit;
if (test_bit(drive, &changed_floppies) || test_bit(drive, &fake_change) if (test_bit(drive, &changed_floppies) || test_bit(drive, &fake_change)
|| unit[drive].disktype == 0) { || unit[drive].disktype == 0) {
...@@ -1176,7 +1177,7 @@ static int floppy_revalidate(dev_t dev) ...@@ -1176,7 +1177,7 @@ static int floppy_revalidate(dev_t dev)
#endif #endif
clear_bit(drive, &fake_change); clear_bit(drive, &fake_change);
clear_bit(drive, &changed_floppies); clear_bit(drive, &changed_floppies);
unit[drive].disktype = 0; p->disktype = 0;
} }
return 0; return 0;
} }
...@@ -1524,8 +1525,8 @@ static struct block_device_operations floppy_fops = ...@@ -1524,8 +1525,8 @@ static struct block_device_operations floppy_fops =
.open = floppy_open, .open = floppy_open,
.release = floppy_release, .release = floppy_release,
.ioctl = fd_ioctl, .ioctl = fd_ioctl,
.check_media_change = check_floppy_change, .media_changed = check_floppy_change,
.revalidate = floppy_revalidate, .revalidate_disk= floppy_revalidate,
}; };
static struct gendisk *floppy_find(dev_t dev, int *part, void *data) static struct gendisk *floppy_find(dev_t dev, int *part, void *data)
...@@ -1538,6 +1539,7 @@ static struct gendisk *floppy_find(dev_t dev, int *part, void *data) ...@@ -1538,6 +1539,7 @@ static struct gendisk *floppy_find(dev_t dev, int *part, void *data)
int fd1772_init(void) int fd1772_init(void)
{ {
static spinlock_t lock = SPIN_LOCK_UNLOCKED;
int i; int i;
if (!machine_is_archimedes()) if (!machine_is_archimedes())
...@@ -1580,13 +1582,15 @@ int fd1772_init(void) ...@@ -1580,13 +1582,15 @@ int fd1772_init(void)
out of some special memory... */ out of some special memory... */
DMABuffer = (char *) kmalloc(2048); /* Copes with pretty large sectors */ DMABuffer = (char *) kmalloc(2048); /* Copes with pretty large sectors */
#endif #endif
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_fd_request); blk_init_queue(&floppy_queue, do_fd_request, &lock);
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);
disks[i]->private_data = &unit[i];
disks[i]->queue = &floppy_queue;
set_capacity(disks[i], MAX_DISK_SIZE * 2); set_capacity(disks[i], MAX_DISK_SIZE * 2);
} }
blk_register_region(MKDEV(MAJOR_NR, 0), 256, THIS_MODULE, blk_register_region(MKDEV(MAJOR_NR, 0), 256, THIS_MODULE,
......
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