X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fblock%2Fcpqarray.c;h=09c14341e6e39582c4230d71ec8bddb384e26610;hb=2fdc86901d2ab30a12402b46238951d2a7891590;hp=b94cd1c321313c17f8a068ef5144ce87102bf3e9;hpb=fb7665544dd60e016494cd5531f5b65ddae22ddc;p=linux-2.6 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index b94cd1c321..09c14341e6 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -161,12 +162,11 @@ static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo); static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io); -static void do_ida_request(request_queue_t *q); +static void do_ida_request(struct request_queue *q); 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; } @@ -391,7 +391,7 @@ static void __devexit cpqarray_remove_one_eisa (int i) /* pdev is NULL for eisa */ static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev) { - request_queue_t *q; + struct request_queue *q; int j; /* @@ -420,18 +420,17 @@ static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev) goto Enomem2; } - hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent( + hba[i]->cmd_pool = pci_alloc_consistent( hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t), &(hba[i]->cmd_pool_dhandle)); - hba[i]->cmd_pool_bits = kmalloc( - ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long), + hba[i]->cmd_pool_bits = kcalloc( + (NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG, sizeof(unsigned long), GFP_KERNEL); if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool) goto Enomem1; memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t)); - memset(hba[i]->cmd_pool_bits, 0, ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long)); printk(KERN_INFO "cpqarray: Finding drives on %s", hba[i]->devname); @@ -886,7 +885,7 @@ static inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c) * are in here (either via the dummy do_ida_request functions or by being * called from the interrupt handler */ -static void do_ida_request(request_queue_t *q) +static void do_ida_request(struct request_queue *q) { ctlr_info_t *h = q->queuedata; cmdlist_t *c; @@ -919,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 */ @@ -930,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); } @@ -979,27 +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) { - int nr_sectors = bio_sectors(bio); - - xbh = bio->bi_next; - bio->bi_next = NULL; - - bio_endio(bio, nr_sectors << 9, 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 && @@ -1011,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; @@ -1030,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(); } /* @@ -1660,45 +1638,30 @@ static void getgeometry(int ctlr) info_p->log_drv_map = 0; - id_ldrive = kmalloc(sizeof(id_log_drv_t), GFP_KERNEL); - if(id_ldrive == NULL) - { + id_ldrive = kzalloc(sizeof(id_log_drv_t), GFP_KERNEL); + if (!id_ldrive) { printk( KERN_ERR "cpqarray: out of memory.\n"); - return; + goto err_0; } - id_ctlr_buf = kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); - if(id_ctlr_buf == NULL) - { - kfree(id_ldrive); + id_ctlr_buf = kzalloc(sizeof(id_ctlr_t), GFP_KERNEL); + if (!id_ctlr_buf) { printk( KERN_ERR "cpqarray: out of memory.\n"); - return; + goto err_1; } - id_lstatus_buf = kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL); - if(id_lstatus_buf == NULL) - { - kfree(id_ctlr_buf); - kfree(id_ldrive); + id_lstatus_buf = kzalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL); + if (!id_lstatus_buf) { printk( KERN_ERR "cpqarray: out of memory.\n"); - return; + goto err_2; } - sense_config_buf = kmalloc(sizeof(config_t), GFP_KERNEL); - if(sense_config_buf == NULL) - { - kfree(id_lstatus_buf); - kfree(id_ctlr_buf); - kfree(id_ldrive); + sense_config_buf = kzalloc(sizeof(config_t), GFP_KERNEL); + if (!sense_config_buf) { printk( KERN_ERR "cpqarray: out of memory.\n"); - return; + goto err_3; } - memset(id_ldrive, 0, sizeof(id_log_drv_t)); - memset(id_ctlr_buf, 0, sizeof(id_ctlr_t)); - memset(id_lstatus_buf, 0, sizeof(sense_log_drv_stat_t)); - memset(sense_config_buf, 0, sizeof(config_t)); - info_p->phys_drives = 0; info_p->log_drv_map = 0; info_p->drv_assign_map = 0; @@ -1712,13 +1675,8 @@ static void getgeometry(int ctlr) * so the idastubopen will fail on all logical drives * on the controller. */ - /* Free all the buffers and return */ printk(KERN_ERR "cpqarray: error sending ID controller\n"); - kfree(sense_config_buf); - kfree(id_lstatus_buf); - kfree(id_ctlr_buf); - kfree(id_ldrive); - return; + goto err_4; } info_p->log_drives = id_ctlr_buf->nr_drvs; @@ -1764,12 +1722,7 @@ static void getgeometry(int ctlr) " failed to report status of logical drive %d\n" "Access to this controller has been disabled\n", ctlr, log_unit); - /* Free all the buffers and return */ - kfree(sense_config_buf); - kfree(id_lstatus_buf); - kfree(id_ctlr_buf); - kfree(id_ldrive); - return; + goto err_4; } /* Make sure the logical drive is configured @@ -1798,14 +1751,8 @@ static void getgeometry(int ctlr) sizeof(config_t), 0, 0, log_unit); if (ret_code == IO_ERROR) { info_p->log_drv_map = 0; - /* Free all the buffers and return */ printk(KERN_ERR "cpqarray: error sending sense config\n"); - kfree(sense_config_buf); - kfree(id_lstatus_buf); - kfree(id_ctlr_buf); - kfree(id_ldrive); - return; - + goto err_4; } info_p->phys_drives = @@ -1820,12 +1767,18 @@ static void getgeometry(int ctlr) log_index = log_index + 1; } /* end of if logical drive configured */ } /* end of for log_unit */ + + /* Free all the buffers and return */ +err_4: kfree(sense_config_buf); - kfree(id_ldrive); +err_3: kfree(id_lstatus_buf); +err_2: kfree(id_ctlr_buf); +err_1: + kfree(id_ldrive); +err_0: return; - } static void __exit cpqarray_exit(void) @@ -1843,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)