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