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

[PATCH] mcdx.c

	* switched to private queue
	* set ->queue
	* switched to use of ->rq_disk
parent 14149d7e
......@@ -317,6 +317,7 @@ static struct s_drive_stuff *mcdx_irq_map[16] = { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
static spinlock_t mcdx_lock = SPIN_LOCK_UNLOCKED;
static struct request_queue mcdx_queue;
MODULE_PARM(mcdx, "1-4i");
static struct cdrom_device_ops mcdx_dops = {
......@@ -575,66 +576,63 @@ static int mcdx_audio_ioctl(struct cdrom_device_info *cdi,
void do_mcdx_request(request_queue_t * q)
{
int dev;
struct s_drive_stuff *stuffp;
struct request *req;
again:
if (blk_queue_empty(QUEUE))
if (blk_queue_empty(q))
return;
dev = minor(CURRENT->rq_dev);
stuffp = mcdx_stuffp[dev];
req = elv_next_request(q);
stuffp = req->rq_disk->private_data;
if ((dev < 0)
|| (dev >= MCDX_NDRIVES)
|| !stuffp || (!stuffp->present)) {
xwarn("do_request(): bad device: %s\n",
kdevname(CURRENT->rq_dev));
if (!stuffp->present) {
xwarn("do_request(): bad device: %s\n",req->rq_disk->disk_name);
xtrace(REQUEST, "end_request(0): bad device\n");
end_request(CURRENT, 0);
end_request(req, 0);
return;
}
if (stuffp->audio) {
xwarn("do_request() attempt to read from audio cd\n");
xtrace(REQUEST, "end_request(0): read from audio\n");
end_request(CURRENT, 0);
end_request(req, 0);
return;
}
xtrace(REQUEST, "do_request() (%lu + %lu)\n",
CURRENT->sector, CURRENT->nr_sectors);
req->sector, req->nr_sectors);
if (CURRENT->cmd != READ) {
if (req->cmd != READ) {
xwarn("do_request(): non-read command to cd!!\n");
xtrace(REQUEST, "end_request(0): write\n");
end_request(CURRENT, 0);
end_request(req, 0);
return;
}
else {
stuffp->status = 0;
while (CURRENT->nr_sectors) {
while (req->nr_sectors) {
int i;
i = mcdx_transfer(stuffp,
CURRENT->buffer,
CURRENT->sector,
CURRENT->nr_sectors);
req->buffer,
req->sector,
req->nr_sectors);
if (i == -1) {
end_request(CURRENT, 0);
end_request(req, 0);
goto again;
}
CURRENT->sector += i;
CURRENT->nr_sectors -= i;
CURRENT->buffer += (i * 512);
req->sector += i;
req->nr_sectors -= i;
req->buffer += (i * 512);
}
end_request(CURRENT, 1);
end_request(req, 1);
goto again;
xtrace(REQUEST, "end_request(1)\n");
end_request(CURRENT, 1);
end_request(req, 1);
}
goto again;
......@@ -1066,10 +1064,10 @@ void __exit mcdx_exit(void)
kfree(stuffp);
}
if (devfs_unregister_blkdev(MAJOR_NR, "mcdx") != 0) {
if (unregister_blkdev(MAJOR_NR, "mcdx") != 0) {
xwarn("cleanup() unregister_blkdev() failed\n");
}
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
blk_cleanup_queue(&mcdx_queue);
#if !MCDX_QUIET
else
xinfo("cleanup() succeeded\n");
......@@ -1204,8 +1202,7 @@ int __init mcdx_init_drive(int drive)
return 1;
}
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_mcdx_request,
&mcdx_lock);
blk_init_queue(&mcdx_queue, do_mcdx_request, &mcdx_lock);
xtrace(INIT, "init() subscribe irq and i/o\n");
mcdx_irq_map[stuffp->irq] = stuffp;
......@@ -1215,7 +1212,7 @@ int __init mcdx_init_drive(int drive)
xwarn("%s=0x%3p,%d: Init failed. Can't get irq (%d).\n",
MCDX, stuffp->wreg_data, stuffp->irq, stuffp->irq);
stuffp->irq = 0;
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
blk_cleanup_queue(&mcdx_queue);
kfree(stuffp);
put_disk(disk);
return 0;
......@@ -1264,10 +1261,11 @@ int __init mcdx_init_drive(int drive)
put_disk(disk);
if (unregister_blkdev(MAJOR_NR, "mcdx") != 0)
xwarn("cleanup() unregister_blkdev() failed\n");
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
blk_cleanup_queue(&mcdx_queue);
return 2;
}
disk->private_data = stuffp;
disk->queue = &mcdx_queue;
add_disk(disk);
printk(msg);
return 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