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

[PATCH] jsfd converted to use of private queue

        * switched to private queues
        * set ->queue and ->private_data
	* switched to use of ->rq_disk
parent dceb2f49
...@@ -190,53 +190,38 @@ static void jsfd_read(char *buf, unsigned long p, size_t togo) { ...@@ -190,53 +190,38 @@ static void jsfd_read(char *buf, unsigned long p, size_t togo) {
static void jsfd_do_request(request_queue_t *q) static void jsfd_do_request(request_queue_t *q)
{ {
struct request *req; while (!blk_queue_empty(q)) {
int dev; struct request *req = elv_next_request(q);
struct jsfd_part *jdp; struct jsfd_part *jdp = req->rq_disk->private_data;
unsigned long offset; unsigned long offset = req->sector << 9;
size_t len; size_t len = req->current_nr_sectors << 9;
for (;;) {
if (blk_queue_empty(QUEUE))
return;
req = CURRENT;
dev = MINOR(req->rq_dev);
if (dev >= JSF_MAX || (dev & JSF_PART_MASK) >= JSF_NPART) {
end_request(CURRENT, 0);
continue;
}
jdp = &jsf0.dv[dev & JSF_PART_MASK];
offset = req->sector << 9;
len = req->current_nr_sectors << 9;
if ((offset + len) > jdp->dsize) { if ((offset + len) > jdp->dsize) {
end_request(CURRENT, 0); end_request(req, 0);
continue; continue;
} }
if (req->cmd == WRITE) { if (req->cmd == WRITE) {
printk(KERN_ERR "jsfd: write\n"); printk(KERN_ERR "jsfd: write\n");
end_request(CURRENT, 0); end_request(req, 0);
continue; continue;
} }
if (req->cmd != READ) { if (req->cmd != READ) {
printk(KERN_ERR "jsfd: bad req->cmd %d\n", req->cmd); printk(KERN_ERR "jsfd: bad req->cmd %d\n", req->cmd);
end_request(CURRENT, 0); end_request(req, 0);
continue; continue;
} }
if ((jdp->dbase & 0xff000000) != 0x20000000) { if ((jdp->dbase & 0xff000000) != 0x20000000) {
printk(KERN_ERR "jsfd: bad base %x\n", (int)jdp->dbase); printk(KERN_ERR "jsfd: bad base %x\n", (int)jdp->dbase);
end_request(CURRENT, 0); end_request(req, 0);
continue; continue;
} }
/* printk("jsfd%d: read buf %p off %x len %x\n", dev, req->buffer, (int)offset, (int)len); */ /* P3 */ /* printk("%s: read buf %p off %x len %x\n", req->rq_disk->disk_name, req->buffer, (int)offset, (int)len); */ /* P3 */
jsfd_read(req->buffer, jdp->dbase + offset, len); jsfd_read(req->buffer, jdp->dbase + offset, len);
end_request(CURRENT, 1); end_request(req, 1);
} }
} }
...@@ -564,6 +549,8 @@ static int jsflash_init(void) ...@@ -564,6 +549,8 @@ static int jsflash_init(void)
return 0; return 0;
} }
static struct request_queue jsf_queue;
static int jsfd_init(void) static int jsfd_init(void)
{ {
static spinlock_t lock = SPIN_LOCK_UNLOCKED; static spinlock_t lock = SPIN_LOCK_UNLOCKED;
...@@ -590,7 +577,7 @@ static int jsfd_init(void) ...@@ -590,7 +577,7 @@ static int jsfd_init(void)
goto out; goto out;
} }
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), jsfd_do_request, &lock); blk_init_queue(&jsf_queue, jsfd_do_request, &lock);
for (i = 0; i < JSF_MAX; i++) { for (i = 0; i < JSF_MAX; i++) {
struct gendisk *disk = jsfd_disk[i]; struct gendisk *disk = jsfd_disk[i];
if ((i & JSF_PART_MASK) >= JSF_NPART) continue; if ((i & JSF_PART_MASK) >= JSF_NPART) continue;
...@@ -602,6 +589,8 @@ static int jsfd_init(void) ...@@ -602,6 +589,8 @@ static int jsfd_init(void)
sprintf(disk->disk_name, "jsfd%d", i); sprintf(disk->disk_name, "jsfd%d", i);
disk->fops = &jsfd_fops; disk->fops = &jsfd_fops;
set_capacity(disk, jdp->dsize >> 9); set_capacity(disk, jdp->dsize >> 9);
disk->private_data = jdp;
disk->queue = &jsf_queue;
add_disk(disk); add_disk(disk);
set_device_ro(MKDEV(JSFD_MAJOR, i), 1); set_device_ro(MKDEV(JSFD_MAJOR, i), 1);
} }
...@@ -641,7 +630,7 @@ static void __exit jsflash_cleanup_module(void) ...@@ -641,7 +630,7 @@ static void __exit jsflash_cleanup_module(void)
misc_deregister(&jsf_dev); misc_deregister(&jsf_dev);
if (unregister_blkdev(JSFD_MAJOR, "jsfd") != 0) if (unregister_blkdev(JSFD_MAJOR, "jsfd") != 0)
printk("jsfd: cleanup_module failed\n"); printk("jsfd: cleanup_module failed\n");
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blk_cleanup_queue(&jsf_queue);
} }
module_init(jsflash_init_module); module_init(jsflash_init_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