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

[PATCH] floppy

	* switched to private queues
	* set ->queue and ->private_data
	* switched to new methods
parent e635a53f
...@@ -243,13 +243,13 @@ static int irqdma_allocated; ...@@ -243,13 +243,13 @@ static int irqdma_allocated;
#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 DEVICE_NR(device) ( (minor(device) & 3) | ((minor(device) & 0x80 ) >> 5 ))
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/blkpg.h> #include <linux/blkpg.h>
#include <linux/cdrom.h> /* for the compatibility eject ioctl */ #include <linux/cdrom.h> /* for the compatibility eject ioctl */
#include <linux/completion.h> #include <linux/completion.h>
static struct request *current_req; static struct request *current_req;
static struct request_queue floppy_queue;
#ifndef fd_get_dma_residue #ifndef fd_get_dma_residue
#define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA) #define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA)
...@@ -2295,12 +2295,10 @@ static int do_format(kdev_t device, struct format_descr *tmp_format_req) ...@@ -2295,12 +2295,10 @@ static int do_format(kdev_t device, struct format_descr *tmp_format_req)
static inline void end_request(struct request *req, int uptodate) static inline void end_request(struct request *req, int uptodate)
{ {
kdev_t dev = req->rq_dev;
if (end_that_request_first(req, uptodate, current_count_sectors)) if (end_that_request_first(req, uptodate, current_count_sectors))
return; return;
add_blkdev_randomness(major(dev)); add_blkdev_randomness(MAJOR_NR);
floppy_off(DEVICE_NR(dev)); floppy_off((int)req->rq_disk->private_data);
blkdev_dequeue_request(req); blkdev_dequeue_request(req);
end_that_request_last(req); end_that_request_last(req);
...@@ -2313,7 +2311,7 @@ static inline void end_request(struct request *req, int uptodate) ...@@ -2313,7 +2311,7 @@ static inline void end_request(struct request *req, int uptodate)
* logical buffer */ * logical buffer */
static void request_done(int uptodate) static void request_done(int uptodate)
{ {
struct request_queue *q = QUEUE; struct request_queue *q = &floppy_queue;
struct request *req = current_req; struct request *req = current_req;
unsigned long flags; unsigned long flags;
int block; int block;
...@@ -2913,7 +2911,7 @@ static void redo_fd_request(void) ...@@ -2913,7 +2911,7 @@ static void redo_fd_request(void)
for (;;) { for (;;) {
if (!current_req) { if (!current_req) {
struct request *req = elv_next_request(QUEUE); struct request *req = elv_next_request(&floppy_queue);
if (!req) { if (!req) {
do_floppy = NULL; do_floppy = NULL;
unlock_fdc(); unlock_fdc();
...@@ -2921,9 +2919,6 @@ static void redo_fd_request(void) ...@@ -2921,9 +2919,6 @@ static void redo_fd_request(void)
} }
current_req = req; current_req = req;
} }
if (major(current_req->rq_dev) != MAJOR_NR)
panic(DEVICE_NAME ": request list destroyed");
device = current_req->rq_dev; device = current_req->rq_dev;
set_fdc(DRIVE(device)); set_fdc(DRIVE(device));
reschedule_timeout(current_reqD, "redo fd request", 0); reschedule_timeout(current_reqD, "redo fd request", 0);
...@@ -3796,14 +3791,9 @@ static int floppy_open(struct inode * inode, struct file * filp) ...@@ -3796,14 +3791,9 @@ static int floppy_open(struct inode * inode, struct file * filp)
/* /*
* Check if the disk has been changed or if a change has been faked. * Check if the disk has been changed or if a change has been faked.
*/ */
static int check_floppy_change(kdev_t dev) static int check_floppy_change(struct gendisk *disk)
{ {
int drive = DRIVE(dev); int drive = (int)disk->private_data;
if (major(dev) != MAJOR_NR) {
DPRINT("check_floppy_change: not a floppy\n");
return 0;
}
if (UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY)) if (UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY))
return 1; return 1;
...@@ -3822,7 +3812,7 @@ static int check_floppy_change(kdev_t dev) ...@@ -3822,7 +3812,7 @@ static int check_floppy_change(kdev_t dev)
if (UTESTF(FD_DISK_CHANGED) || if (UTESTF(FD_DISK_CHANGED) ||
UTESTF(FD_VERIFY) || UTESTF(FD_VERIFY) ||
test_bit(drive, &fake_change) || test_bit(drive, &fake_change) ||
(!TYPE(dev) && !current_type[drive])) (!ITYPE(UDRS->fd_device) && !current_type[drive]))
return 1; return 1;
return 0; return 0;
} }
...@@ -3884,16 +3874,17 @@ static int __floppy_read_block_0(struct block_device *bdev) ...@@ -3884,16 +3874,17 @@ static int __floppy_read_block_0(struct block_device *bdev)
return 0; return 0;
} }
static int floppy_read_block_0(kdev_t dev) static int floppy_read_block_0(struct gendisk *disk)
{ {
struct block_device *bdev; struct block_device *bdev;
int ret; int ret;
bdev = bdget(kdev_t_to_nr(dev)); bdev = bdget(MKDEV(disk->major, disk->first_minor));
if (!bdev) { if (!bdev) {
printk("No block device for %s\n", __bdevname(dev)); printk("No block device for %s\n", disk->disk_name);
BUG(); BUG();
} }
bdev->bd_disk = disk; /* ewww */
ret = __floppy_read_block_0(bdev); ret = __floppy_read_block_0(bdev);
atomic_dec(&bdev->bd_count); atomic_dec(&bdev->bd_count);
return ret; return ret;
...@@ -3903,10 +3894,10 @@ static int floppy_read_block_0(kdev_t dev) ...@@ -3903,10 +3894,10 @@ static int floppy_read_block_0(kdev_t dev)
* the bootblock (block 0). "Autodetection" is also needed to check whether * the bootblock (block 0). "Autodetection" is also needed to check whether
* there is a disk in the drive at all... Thus we also do it for fixed * there is a disk in the drive at all... Thus we also do it for fixed
* geometry formats */ * geometry formats */
static int floppy_revalidate(kdev_t dev) static int floppy_revalidate(struct gendisk *disk)
{ {
#define NO_GEOM (!current_type[drive] && !TYPE(dev)) int drive=(int)disk->private_data;
int drive=DRIVE(dev); #define NO_GEOM (!current_type[drive] && !ITYPE(UDRS->fd_device))
int cf; int cf;
int res = 0; int res = 0;
...@@ -3934,24 +3925,24 @@ static int floppy_revalidate(kdev_t dev) ...@@ -3934,24 +3925,24 @@ static int floppy_revalidate(kdev_t dev)
UDRS->generation++; UDRS->generation++;
if (NO_GEOM){ if (NO_GEOM){
/* auto-sensing */ /* auto-sensing */
res = floppy_read_block_0(dev); res = floppy_read_block_0(disk);
} else { } else {
if (cf) if (cf)
poll_drive(0, FD_RAW_NEED_DISK); poll_drive(0, FD_RAW_NEED_DISK);
process_fd_request(); process_fd_request();
} }
} }
set_capacity(disks[drive], floppy_sizes[minor(dev)]); set_capacity(disk, floppy_sizes[UDRS->fd_device]);
return res; return res;
} }
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: check_floppy_change, .media_changed = check_floppy_change,
revalidate: floppy_revalidate, .revalidate_disk= floppy_revalidate,
}; };
static void __init register_devfs_entries (int drive) static void __init register_devfs_entries (int drive)
...@@ -4258,7 +4249,7 @@ int __init floppy_init(void) ...@@ -4258,7 +4249,7 @@ int __init floppy_init(void)
else else
floppy_sizes[i] = MAX_DISK_SIZE << 1; floppy_sizes[i] = MAX_DISK_SIZE << 1;
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_fd_request, &floppy_lock); blk_init_queue(&floppy_queue, do_fd_request, &floppy_lock);
reschedule_timeout(MAXTIMEOUT, "floppy init", MAXTIMEOUT); reschedule_timeout(MAXTIMEOUT, "floppy init", MAXTIMEOUT);
config_types(); config_types();
...@@ -4360,6 +4351,9 @@ int __init floppy_init(void) ...@@ -4360,6 +4351,9 @@ int __init floppy_init(void)
continue; continue;
if (fdc_state[FDC(drive)].version == FDC_NONE) if (fdc_state[FDC(drive)].version == FDC_NONE)
continue; continue;
/* to be cleaned up... */
disks[drive]->private_data = (void*)drive;
disks[drive]->queue = &floppy_queue;
add_disk(disks[drive]); add_disk(disks[drive]);
} }
...@@ -4371,7 +4365,7 @@ int __init floppy_init(void) ...@@ -4371,7 +4365,7 @@ int __init floppy_init(void)
out2: out2:
blk_unregister_region(MKDEV(MAJOR_NR, 0), 256); blk_unregister_region(MKDEV(MAJOR_NR, 0), 256);
unregister_blkdev(MAJOR_NR,"fd"); unregister_blkdev(MAJOR_NR,"fd");
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blk_cleanup_queue(&floppy_queue);
out: out:
for (i=0; i<N_DRIVE; i++) for (i=0; i<N_DRIVE; i++)
put_disk(disks[i]); put_disk(disks[i]);
...@@ -4573,7 +4567,7 @@ void cleanup_module(void) ...@@ -4573,7 +4567,7 @@ void cleanup_module(void)
put_disk(disks[drive]); put_disk(disks[drive]);
} }
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blk_cleanup_queue(&floppy_queue);
/* eject disk, if any */ /* eject disk, if any */
fd_eject(0); fd_eject(0);
} }
......
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