Merge git://git.infradead.org/~dwmw2/random-2.6
[pandora-kernel.git] / drivers / block / cpqarray.c
index 568603d..09c1434 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/spinlock.h>
 #include <linux/blkdev.h>
 #include <linux/genhd.h>
+#include <linux/scatterlist.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
@@ -166,7 +167,6 @@ static void start_io(ctlr_info_t *h);
 
 static inline void addQ(cmdlist_t **Qptr, cmdlist_t *c);
 static inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c);
-static inline void complete_buffers(struct bio *bio, int ok);
 static inline void complete_command(cmdlist_t *cmd, int timeout);
 
 static irqreturn_t do_ida_intr(int irq, void *dev_id);
@@ -214,7 +214,7 @@ static struct proc_dir_entry *proc_array;
 static void __init ida_procinit(int i)
 {
        if (proc_array == NULL) {
-               proc_array = proc_mkdir("cpqarray", proc_root_driver);
+               proc_array = proc_mkdir("driver/cpqarray", NULL);
                if (!proc_array) return;
        }
 
@@ -918,6 +918,7 @@ queue_next:
 DBGPX(
        printk("sector=%d, nr_sectors=%d\n", creq->sector, creq->nr_sectors);
 );
+       sg_init_table(tmp_sg, SG_MAX);
        seg = blk_rq_map_sg(q, creq, tmp_sg);
 
        /* Now do all the DMA Mappings */
@@ -929,7 +930,7 @@ DBGPX(
        {
                c->req.sg[i].size = tmp_sg[i].length;
                c->req.sg[i].addr = (__u32) pci_map_page(h->pci_dev,
-                                                tmp_sg[i].page,
+                                                sg_page(&tmp_sg[i]),
                                                 tmp_sg[i].offset,
                                                 tmp_sg[i].length, dir);
        }
@@ -978,26 +979,13 @@ static void start_io(ctlr_info_t *h)
        }
 }
 
-static inline void complete_buffers(struct bio *bio, int ok)
-{
-       struct bio *xbh;
-
-       while (bio) {
-               xbh = bio->bi_next;
-               bio->bi_next = NULL;
-               
-               bio_endio(bio, ok ? 0 : -EIO);
-
-               bio = xbh;
-       }
-}
 /*
  * Mark all buffers that cmd was responsible for
  */
 static inline void complete_command(cmdlist_t *cmd, int timeout)
 {
        struct request *rq = cmd->rq;
-       int ok=1;
+       int error = 0;
        int i, ddir;
 
        if (cmd->req.hdr.rcode & RCODE_NONFATAL &&
@@ -1009,16 +997,17 @@ static inline void complete_command(cmdlist_t *cmd, int timeout)
        if (cmd->req.hdr.rcode & RCODE_FATAL) {
                printk(KERN_WARNING "Fatal error on ida/c%dd%d\n",
                                cmd->ctlr, cmd->hdr.unit);
-               ok = 0;
+               error = -EIO;
        }
        if (cmd->req.hdr.rcode & RCODE_INVREQ) {
                                printk(KERN_WARNING "Invalid request on ida/c%dd%d = (cmd=%x sect=%d cnt=%d sg=%d ret=%x)\n",
                                cmd->ctlr, cmd->hdr.unit, cmd->req.hdr.cmd,
                                cmd->req.hdr.blk, cmd->req.hdr.blk_cnt,
                                cmd->req.hdr.sg_cnt, cmd->req.hdr.rcode);
-               ok = 0; 
+               error = -EIO;
        }
-       if (timeout) ok = 0;
+       if (timeout)
+               error = -EIO;
        /* unmap the DMA mapping for all the scatter gather elements */
        if (cmd->req.hdr.cmd == IDA_READ)
                ddir = PCI_DMA_FROMDEVICE;
@@ -1028,18 +1017,9 @@ static inline void complete_command(cmdlist_t *cmd, int timeout)
                 pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr,
                                cmd->req.sg[i].size, ddir);
 
-       complete_buffers(rq->bio, ok);
-
-       if (blk_fs_request(rq)) {
-               const int rw = rq_data_dir(rq);
-
-               disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
-       }
-
-       add_disk_randomness(rq->rq_disk);
-
        DBGPX(printk("Done with %p\n", rq););
-       end_that_request_last(rq, ok ? 1 : -EIO);
+       if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
+               BUG();
 }
 
 /*
@@ -1816,7 +1796,7 @@ static void __exit cpqarray_exit(void)
                }
        }
 
-       remove_proc_entry("cpqarray", proc_root_driver);
+       remove_proc_entry("driver/cpqarray", NULL);
 }
 
 module_init(cpqarray_init)