X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fblock%2Fcciss_scsi.c;h=f16e3caed58a36129ff7046531607ea6cfb07fa3;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=9636ac51e8fe2b8c94f0b0956ad39b62a24ecd20;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index 9636ac51e..f16e3caed 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Questions/Comments/Bugfixes to arrays@compaq.com + * Questions/Comments/Bugfixes to iss_storagedev@hp.com * * Author: Stephen M. Cameron */ @@ -28,8 +28,10 @@ through the array controller. Note in particular, neither physical nor logical disks are presented through the scsi layer. */ -#include "../scsi/scsi.h" -#include "../scsi/hosts.h" +#include +#include +#include +#include #include #include #include @@ -51,9 +53,7 @@ static int sendcmd( int cmd_type); -const char *cciss_scsi_info(struct Scsi_Host *sa); - -int cciss_scsi_proc_info( +static int cciss_scsi_proc_info( struct Scsi_Host *sh, char *buffer, /* data buffer */ char **start, /* where data in buffer starts */ @@ -61,15 +61,8 @@ int cciss_scsi_proc_info( int length, /* length of data in buffer */ int func); /* 0 == read, 1 == write */ -int cciss_scsi_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)); -#if 0 -int cciss_scsi_abort(Scsi_Cmnd *cmd); -#if defined SCSI_RESET_SYNCHRONOUS && defined SCSI_RESET_ASYNCHRONOUS -int cciss_scsi_reset(Scsi_Cmnd *cmd, unsigned int reset_flags); -#else -int cciss_scsi_reset(Scsi_Cmnd *cmd); -#endif -#endif +static int cciss_scsi_queue_command (struct scsi_cmnd *cmd, + void (* done)(struct scsi_cmnd *)); static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = { { .name = "cciss0", .ndevices = 0 }, @@ -82,7 +75,7 @@ static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = { { .name = "cciss7", .ndevices = 0 }, }; -static Scsi_Host_Template cciss_driver_template = { +static struct scsi_host_template cciss_driver_template = { .module = THIS_MODULE, .name = "cciss", .proc_name = "cciss", @@ -539,7 +532,7 @@ cciss_scsi_setup(int cntl_num) if (shba == NULL) return; shba->scsi_host = NULL; - shba->lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&shba->lock); shba->registered = 0; if (scsi_cmd_stack_setup(cntl_num, shba) != 0) { kfree(shba); @@ -552,7 +545,7 @@ cciss_scsi_setup(int cntl_num) static void complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag) { - Scsi_Cmnd *cmd; + struct scsi_cmnd *cmd; ctlr_info_t *ctlr; u64bit addr64; ErrorInfo_struct *ei; @@ -565,7 +558,7 @@ complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag) return; } - cmd = (Scsi_Cmnd *) cp->scsi_cmd; + cmd = (struct scsi_cmnd *) cp->scsi_cmd; ctlr = hba[cp->ctlr]; /* undo the DMA mappings */ @@ -573,14 +566,14 @@ complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag) if (cmd->use_sg) { pci_unmap_sg(ctlr->pdev, cmd->buffer, cmd->use_sg, - scsi_to_pci_dma_dir(cmd->sc_data_direction)); + cmd->sc_data_direction); } else if (cmd->request_bufflen) { addr64.val32.lower = cp->SG[0].Addr.lower; addr64.val32.upper = cp->SG[0].Addr.upper; pci_unmap_single(ctlr->pdev, (dma_addr_t) addr64.val, cmd->request_bufflen, - scsi_to_pci_dma_dir(cmd->sc_data_direction)); + cmd->sc_data_direction); } cmd->result = (DID_OK << 16); /* host byte */ @@ -696,14 +689,13 @@ static int cciss_scsi_detect(int ctlr) { struct Scsi_Host *sh; + int error; sh = scsi_host_alloc(&cciss_driver_template, sizeof(struct ctlr_info *)); if (sh == NULL) - return 0; - + goto fail; sh->io_port = 0; // good enough? FIXME, sh->n_io_port = 0; // I don't think we use these two... - sh->this_id = SELF_SCSI_ID; ((struct cciss_scsi_adapter_data_t *) @@ -711,13 +703,17 @@ cciss_scsi_detect(int ctlr) sh->hostdata[0] = (unsigned long) hba[ctlr]; sh->irq = hba[ctlr]->intr; sh->unique_id = sh->irq; - scsi_add_host(sh, &hba[ctlr]->pdev->dev); /* XXX handle failure */ + error = scsi_add_host(sh, &hba[ctlr]->pdev->dev); + if (error) + goto fail_host_put; scsi_scan_host(sh); - return 1; -} -static void __exit cleanup_cciss_module(void); + fail_host_put: + scsi_host_put(sh); + fail: + return 0; +} static void cciss_unmap_one(struct pci_dev *pdev, @@ -783,9 +779,8 @@ cciss_scsi_do_simple_cmd(ctlr_info_t *c, cp->Request.Type.Direction = direction; /* Fill in the SG list and do dma mapping */ - cciss_map_one(c->pdev, cp, - (unsigned char *) buf, bufsize, - scsi_to_pci_dma_dir(SCSI_DATA_READ)); + cciss_map_one(c->pdev, cp, (unsigned char *) buf, + bufsize, DMA_FROM_DEVICE); cp->waiting = &wait; @@ -799,9 +794,7 @@ cciss_scsi_do_simple_cmd(ctlr_info_t *c, wait_for_completion(&wait); /* undo the dma mapping */ - cciss_unmap_one(c->pdev, cp, bufsize, - scsi_to_pci_dma_dir(SCSI_DATA_READ)); - + cciss_unmap_one(c->pdev, cp, bufsize, DMA_FROM_DEVICE); return(0); } @@ -1122,7 +1115,7 @@ cciss_scsi_user_command(int ctlr, int hostno, char *buffer, int length) } -int +static int cciss_scsi_proc_info(struct Scsi_Host *sh, char *buffer, /* data buffer */ char **start, /* where data in buffer starts */ @@ -1157,37 +1150,14 @@ cciss_scsi_proc_info(struct Scsi_Host *sh, buffer, length); } -/* this is via the generic proc support */ -const char * -cciss_scsi_info(struct Scsi_Host *sa) -{ - static char buf[300]; - ctlr_info_t *ci; - - /* probably need to work on putting a bit more info in here... */ - /* this is output via the /proc filesystem. */ - - ci = (ctlr_info_t *) sa->hostdata[0]; - - sprintf(buf, "%s %c%c%c%c\n", - ci->product_name, - ci->firm_ver[0], - ci->firm_ver[1], - ci->firm_ver[2], - ci->firm_ver[3]); - - return buf; -} - - -/* cciss_scatter_gather takes a Scsi_Cmnd, (cmd), and does the pci +/* cciss_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci dma mapping and fills in the scatter gather entries of the cciss command, cp. */ static void cciss_scatter_gather(struct pci_dev *pdev, CommandList_struct *cp, - Scsi_Cmnd *cmd) + struct scsi_cmnd *cmd) { unsigned int use_sg, nsegs=0, len; struct scatterlist *scatter = (struct scatterlist *) cmd->buffer; @@ -1200,7 +1170,7 @@ cciss_scatter_gather(struct pci_dev *pdev, addr64 = (__u64) pci_map_single(pdev, cmd->request_buffer, cmd->request_bufflen, - scsi_to_pci_dma_dir(cmd->sc_data_direction)); + cmd->sc_data_direction); cp->SG[0].Addr.lower = (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF); @@ -1213,7 +1183,7 @@ cciss_scatter_gather(struct pci_dev *pdev, else if (cmd->use_sg <= MAXSGENTRIES) { /* not too many addrs? */ use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg, - scsi_to_pci_dma_dir(cmd->sc_data_direction)); + cmd->sc_data_direction); for (nsegs=0; nsegs < use_sg; nsegs++) { addr64 = (__u64) sg_dma_address(&scatter[nsegs]); @@ -1233,8 +1203,8 @@ cciss_scatter_gather(struct pci_dev *pdev, } -int -cciss_scsi_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) +static int +cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) { ctlr_info_t **c; int ctlr, rc; @@ -1302,11 +1272,10 @@ cciss_scsi_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) cp->Request.Type.Attribute = ATTR_SIMPLE; switch(cmd->sc_data_direction) { - case SCSI_DATA_WRITE: cp->Request.Type.Direction = XFER_WRITE; break; - case SCSI_DATA_READ: cp->Request.Type.Direction = XFER_READ; break; - case SCSI_DATA_NONE: cp->Request.Type.Direction = XFER_NONE; break; - - case SCSI_DATA_UNKNOWN: + case DMA_TO_DEVICE: cp->Request.Type.Direction = XFER_WRITE; break; + case DMA_FROM_DEVICE: cp->Request.Type.Direction = XFER_READ; break; + case DMA_NONE: cp->Request.Type.Direction = XFER_NONE; break; + case DMA_BIDIRECTIONAL: // This can happen if a buggy application does a scsi passthru // and sets both inlen and outlen to non-zero. ( see // ../scsi/scsi_ioctl.c:scsi_ioctl_send_command() )