X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fscsi%2Fnsp32.c;h=7c13f6f4a4c653d77596ed9cc005820041068180;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=d28c0d99c3442c79808887672c1f78d26b7bfa94;hpb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;p=linux-2.6.git diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index d28c0d99c..7c13f6f4a 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -198,7 +199,7 @@ static void __devexit nsp32_remove(struct pci_dev *); static int __init init_nsp32 (void); static void __exit exit_nsp32 (void); -/* struct Scsi_Host_Template */ +/* struct struct scsi_host_template */ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) static int nsp32_proc_info (struct Scsi_Host *, char *, char **, off_t, int, int); #else @@ -208,7 +209,7 @@ static int nsp32_proc_info (char *, char **, off_t, int, int, int); #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) static int nsp32_detect (struct pci_dev *pdev); #else -static int nsp32_detect (Scsi_Host_Template *); +static int nsp32_detect (struct scsi_host_template *); #endif static int nsp32_queuecommand(struct scsi_cmnd *, void (*done)(struct scsi_cmnd *)); @@ -255,7 +256,7 @@ static void nsp32_sack_negate (nsp32_hw_data *); static void nsp32_do_bus_reset(nsp32_hw_data *); /* hardware interrupt handler */ -static irqreturn_t do_nsp32_isr(int, void *, struct pt_regs *); +static irqreturn_t do_nsp32_isr(int, void *); /* initialize hardware */ static int nsp32hw_init(nsp32_hw_data *); @@ -294,7 +295,6 @@ static struct scsi_host_template nsp32_template = { .this_id = NSP32_HOST_SCSIID, .use_clustering = DISABLE_CLUSTERING, .eh_abort_handler = nsp32_eh_abort, -/* .eh_device_reset_handler = NULL, */ .eh_bus_reset_handler = nsp32_eh_bus_reset, .eh_host_reset_handler = nsp32_eh_host_reset, #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74)) @@ -482,7 +482,7 @@ static int nsp32_selection_autopara(struct scsi_cmnd *SCpnt) nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; unsigned int base = SCpnt->device->host->io_port; unsigned int host_id = SCpnt->device->host->this_id; - unsigned char target = SCpnt->device->id; + unsigned char target = scmd_id(SCpnt); nsp32_autoparam *param = data->autoparam; unsigned char phase; int i, ret; @@ -613,7 +613,7 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; unsigned int base = SCpnt->device->host->io_port; unsigned int host_id = SCpnt->device->host->this_id; - unsigned char target = SCpnt->device->id; + unsigned char target = scmd_id(SCpnt); unsigned char phase; int status; unsigned short command = 0; @@ -974,7 +974,7 @@ static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_ } /* check target ID is not same as this initiator ID */ - if (SCpnt->device->id == SCpnt->device->host->this_id) { + if (scmd_id(SCpnt) == SCpnt->device->host->this_id) { nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "terget==host???"); SCpnt->result = DID_BAD_TARGET << 16; done(SCpnt); @@ -1029,7 +1029,7 @@ static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_ * (target don't have SDTR_DONE and SDTR_INITIATOR), sync * message SDTR is needed to do synchronous transfer. */ - target = &data->target[SCpnt->device->id]; + target = &data->target[scmd_id(SCpnt)]; data->cur_target = target; if (!(target->sync_flag & (SDTR_DONE | SDTR_INITIATOR | SDTR_TARGET))) { @@ -1201,7 +1201,7 @@ static int nsp32hw_init(nsp32_hw_data *data) /* interrupt routine */ -static irqreturn_t do_nsp32_isr(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t do_nsp32_isr(int irq, void *dev_id) { nsp32_hw_data *data = dev_id; unsigned int base = data->BaseAddress; @@ -1636,7 +1636,7 @@ static void nsp32_scsi_done(struct scsi_cmnd *SCpnt) if (SCpnt->use_sg) { pci_unmap_sg(data->Pci, - (struct scatterlist *)SCpnt->buffer, + (struct scatterlist *)SCpnt->request_buffer, SCpnt->use_sg, SCpnt->sc_data_direction); } else { pci_unmap_single(data->Pci, @@ -2684,7 +2684,7 @@ static int nsp32_detect(struct pci_dev *pdev) #define DETECT_OK 1 #define DETECT_NG 0 #define PCIDEV (data->Pci) -static int nsp32_detect(Scsi_Host_Template *sht) +static int nsp32_detect(struct scsi_host_template *sht) #endif { struct Scsi_Host *host; /* registered host structure */ @@ -2720,9 +2720,7 @@ static int nsp32_detect(Scsi_Host_Template *sht) host->unique_id = data->BaseAddress; host->n_io_port = data->NumAddress; host->base = (unsigned long)data->MmioAddress; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,63)) - scsi_set_device(host, &PCIDEV->dev); -#else +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,63)) scsi_set_pci_device(host, PCIDEV); #endif @@ -2779,7 +2777,7 @@ static int nsp32_detect(Scsi_Host_Template *sht) /* * setup DMA */ - if (pci_set_dma_mask(PCIDEV, 0xffffffffUL) != 0) { + if (pci_set_dma_mask(PCIDEV, DMA_32BIT_MASK) != 0) { nsp32_msg (KERN_ERR, "failed to set PCI DMA mask"); goto scsi_unregister; } @@ -2868,8 +2866,7 @@ static int nsp32_detect(Scsi_Host_Template *sht) */ nsp32_do_bus_reset(data); - ret = request_irq(host->irq, do_nsp32_isr, - SA_SHIRQ | SA_SAMPLE_RANDOM, "nsp32", data); + ret = request_irq(host->irq, do_nsp32_isr, IRQF_SHARED, "nsp32", data); if (ret < 0) { nsp32_msg(KERN_ERR, "Unable to allocate IRQ for NinjaSCSI32 " "SCSI PCI controller. Interrupt: %d", host->irq); @@ -2888,12 +2885,19 @@ static int nsp32_detect(Scsi_Host_Template *sht) } #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) - scsi_add_host (host, &PCIDEV->dev); + ret = scsi_add_host(host, &PCIDEV->dev); + if (ret) { + nsp32_msg(KERN_ERR, "failed to add scsi host"); + goto free_region; + } scsi_scan_host(host); #endif pci_set_drvdata(PCIDEV, host); return DETECT_OK; + free_region: + release_region(host->io_port, host->n_io_port); + free_irq: free_irq(host->irq, data); @@ -2988,6 +2992,8 @@ static int nsp32_eh_bus_reset(struct scsi_cmnd *SCpnt) nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; unsigned int base = SCpnt->device->host->io_port; + spin_lock_irq(SCpnt->device->host->host_lock); + nsp32_msg(KERN_INFO, "Bus Reset"); nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt); @@ -2995,6 +3001,7 @@ static int nsp32_eh_bus_reset(struct scsi_cmnd *SCpnt) nsp32_do_bus_reset(data); nsp32_write2(base, IRQ_CONTROL, 0); + spin_unlock_irq(SCpnt->device->host->host_lock); return SUCCESS; /* SCSI bus reset is succeeded at any time. */ } @@ -3049,11 +3056,14 @@ static int nsp32_eh_host_reset(struct scsi_cmnd *SCpnt) nsp32_msg(KERN_INFO, "Host Reset"); nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt); + spin_lock_irq(SCpnt->device->host->host_lock); + nsp32hw_init(data); nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); nsp32_do_bus_reset(data); nsp32_write2(base, IRQ_CONTROL, 0); + spin_unlock_irq(SCpnt->device->host->host_lock); return SUCCESS; /* Host reset is succeeded at any time. */ } @@ -3571,7 +3581,7 @@ static struct pci_driver nsp32_driver = { */ static int __init init_nsp32(void) { nsp32_msg(KERN_INFO, "loading..."); - return pci_module_init(&nsp32_driver); + return pci_register_driver(&nsp32_driver); } static void __exit exit_nsp32(void) {