- spin_unlock_irq(&driver_lock);
- sh[j] = scsi_register(tpnt, sizeof(struct hostdata));
- spin_lock_irq(&driver_lock);
-
- if (sh[j] == NULL) {
- printk("%s: unable to register host, detaching.\n", name);
- goto freedma;
- }
-
- sh[j]->io_port = port_base;
- sh[j]->unique_id = port_base;
- sh[j]->n_io_port = REGION_SIZE;
- sh[j]->dma_channel = dma_channel;
- sh[j]->irq = irq;
- sh[j]->sg_tablesize = (ushort) info.scatt_size;
- sh[j]->this_id = (ushort) info.host_addr[3];
- sh[j]->can_queue = (ushort) info.queue_size;
- sh[j]->cmd_per_lun = MAX_CMD_PER_LUN;
- memset(HD(j), 0, sizeof(struct hostdata));
- HD(j)->subversion = subversion;
- HD(j)->protocol_rev = protocol_rev;
- HD(j)->is_pci = is_pci;
- HD(j)->pdev = pdev;
- HD(j)->board_number = j;
-
- if (HD(j)->subversion == ESA)
- sh[j]->unchecked_isa_dma = FALSE;
- else {
- unsigned long flags;
- sh[j]->unchecked_isa_dma = TRUE;
-
- flags=claim_dma_lock();
- disable_dma(dma_channel);
- clear_dma_ff(dma_channel);
- set_dma_mode(dma_channel, DMA_MODE_CASCADE);
- enable_dma(dma_channel);
- release_dma_lock(flags);
-
- }
-
- strcpy(BN(j), name);
-
- /* DPT PM2012 does not allow to detect sg_tablesize correctly */
- if (sh[j]->sg_tablesize > MAX_SGLIST || sh[j]->sg_tablesize < 2) {
- printk("%s: detect, wrong n. of SG lists %d, fixed.\n",
- BN(j), sh[j]->sg_tablesize);
- sh[j]->sg_tablesize = MAX_SGLIST;
- }
-
- /* DPT PM2012 does not allow to detect can_queue correctly */
- if (sh[j]->can_queue > MAX_MAILBOXES || sh[j]->can_queue < 2) {
- printk("%s: detect, wrong n. of mbox %d, fixed.\n",
- BN(j), sh[j]->can_queue);
- sh[j]->can_queue = MAX_MAILBOXES;
- }
-
- if (protocol_rev != 'A') {
-
- if (info.max_chan > 0 && info.max_chan < MAX_CHANNEL)
- sh[j]->max_channel = info.max_chan;
-
- if (info.max_id > 7 && info.max_id < MAX_TARGET)
- sh[j]->max_id = info.max_id + 1;
-
- if (info.large_sg && sh[j]->sg_tablesize == MAX_SGLIST)
- sh[j]->sg_tablesize = MAX_LARGE_SGLIST;
- }
-
- if (protocol_rev == 'C') {
-
- if (info.max_lun > 7 && info.max_lun < MAX_LUN)
- sh[j]->max_lun = info.max_lun + 1;
- }
-
- if (dma_channel == NO_DMA) sprintf(dma_name, "%s", "BMST");
- else sprintf(dma_name, "DMA %u", dma_channel);
-
- spin_unlock_irq(&driver_lock);
-
- for (i = 0; i < sh[j]->can_queue; i++)
- HD(j)->cp[i].cp_dma_addr = pci_map_single(HD(j)->pdev,
- &HD(j)->cp[i], sizeof(struct mscp), PCI_DMA_BIDIRECTIONAL);
-
- for (i = 0; i < sh[j]->can_queue; i++)
- if (! ((&HD(j)->cp[i])->sglist = kmalloc(
- sh[j]->sg_tablesize * sizeof(struct sg_list),
- (sh[j]->unchecked_isa_dma ? GFP_DMA : 0) | GFP_ATOMIC))) {
- printk("%s: kmalloc SGlist failed, mbox %d, detaching.\n", BN(j), i);
- goto release;
- }
-
- if (! (HD(j)->sp_cpu_addr = pci_alloc_consistent(HD(j)->pdev,
- sizeof(struct mssp), &HD(j)->sp_dma_addr))) {
- printk("%s: pci_alloc_consistent failed, detaching.\n", BN(j));
- goto release;
- }
-
- if (max_queue_depth > MAX_TAGGED_CMD_PER_LUN)
- max_queue_depth = MAX_TAGGED_CMD_PER_LUN;
-
- if (max_queue_depth < MAX_CMD_PER_LUN) max_queue_depth = MAX_CMD_PER_LUN;
-
- if (tag_mode != TAG_DISABLED && tag_mode != TAG_SIMPLE)
- tag_mode = TAG_ORDERED;
-
- if (j == 0) {
- printk("EATA/DMA 2.0x: Copyright (C) 1994-2003 Dario Ballabio.\n");
- printk("%s config options -> tm:%d, lc:%c, mq:%d, rs:%c, et:%c, "\
- "ip:%c, ep:%c, pp:%c.\n", driver_name, tag_mode,
- YESNO(linked_comm), max_queue_depth, YESNO(rev_scan),
- YESNO(ext_tran), YESNO(isa_probe), YESNO(eisa_probe),
- YESNO(pci_probe));
- }
-
- printk("%s: 2.0%c, %s 0x%03lx, IRQ %u, %s, SG %d, MB %d.\n",
- BN(j), HD(j)->protocol_rev, bus_type, (unsigned long)sh[j]->io_port,
- sh[j]->irq, dma_name, sh[j]->sg_tablesize, sh[j]->can_queue);
-
- if (sh[j]->max_id > 8 || sh[j]->max_lun > 8)
- printk("%s: wide SCSI support enabled, max_id %u, max_lun %u.\n",
- BN(j), sh[j]->max_id, sh[j]->max_lun);
-
- for (i = 0; i <= sh[j]->max_channel; i++)
- printk("%s: SCSI channel %u enabled, host target ID %d.\n",
- BN(j), i, info.host_addr[3 - i]);
+ spin_unlock_irq(&driver_lock);
+ sh[j] = shost = scsi_register(tpnt, sizeof(struct hostdata));
+ spin_lock_irq(&driver_lock);
+
+ if (shost == NULL) {
+ printk("%s: unable to register host, detaching.\n", name);
+ goto freedma;
+ }
+
+ shost->io_port = port_base;
+ shost->unique_id = port_base;
+ shost->n_io_port = REGION_SIZE;
+ shost->dma_channel = dma_channel;
+ shost->irq = irq;
+ shost->sg_tablesize = (ushort) info.scatt_size;
+ shost->this_id = (ushort) info.host_addr[3];
+ shost->can_queue = (ushort) info.queue_size;
+ shost->cmd_per_lun = MAX_CMD_PER_LUN;
+
+ ha = (struct hostdata *)shost->hostdata;
+
+ memset(ha, 0, sizeof(struct hostdata));
+ ha->subversion = subversion;
+ ha->protocol_rev = protocol_rev;
+ ha->is_pci = is_pci;
+ ha->pdev = pdev;
+ ha->board_number = j;
+
+ if (ha->subversion == ESA)
+ shost->unchecked_isa_dma = 0;
+ else {
+ unsigned long flags;
+ shost->unchecked_isa_dma = 1;
+
+ flags = claim_dma_lock();
+ disable_dma(dma_channel);
+ clear_dma_ff(dma_channel);
+ set_dma_mode(dma_channel, DMA_MODE_CASCADE);
+ enable_dma(dma_channel);
+ release_dma_lock(flags);
+
+ }
+
+ strcpy(ha->board_name, name);
+
+ /* DPT PM2012 does not allow to detect sg_tablesize correctly */
+ if (shost->sg_tablesize > MAX_SGLIST || shost->sg_tablesize < 2) {
+ printk("%s: detect, wrong n. of SG lists %d, fixed.\n",
+ ha->board_name, shost->sg_tablesize);
+ shost->sg_tablesize = MAX_SGLIST;
+ }
+
+ /* DPT PM2012 does not allow to detect can_queue correctly */
+ if (shost->can_queue > MAX_MAILBOXES || shost->can_queue < 2) {
+ printk("%s: detect, wrong n. of mbox %d, fixed.\n",
+ ha->board_name, shost->can_queue);
+ shost->can_queue = MAX_MAILBOXES;
+ }
+
+ if (protocol_rev != 'A') {
+ if (info.max_chan > 0 && info.max_chan < MAX_CHANNEL)
+ shost->max_channel = info.max_chan;
+
+ if (info.max_id > 7 && info.max_id < MAX_TARGET)
+ shost->max_id = info.max_id + 1;
+
+ if (info.large_sg && shost->sg_tablesize == MAX_SGLIST)
+ shost->sg_tablesize = MAX_LARGE_SGLIST;
+ }
+
+ if (protocol_rev == 'C') {
+ if (info.max_lun > 7 && info.max_lun < MAX_LUN)
+ shost->max_lun = info.max_lun + 1;
+ }
+
+ if (dma_channel == NO_DMA)
+ sprintf(dma_name, "%s", "BMST");
+ else
+ sprintf(dma_name, "DMA %u", dma_channel);
+
+ spin_unlock_irq(&driver_lock);
+
+ for (i = 0; i < shost->can_queue; i++)
+ ha->cp[i].cp_dma_addr = pci_map_single(ha->pdev,
+ &ha->cp[i],
+ sizeof(struct mscp),
+ PCI_DMA_BIDIRECTIONAL);
+
+ for (i = 0; i < shost->can_queue; i++) {
+ size_t sz = shost->sg_tablesize *sizeof(struct sg_list);
+ gfp_t gfp_mask = (shost->unchecked_isa_dma ? GFP_DMA : 0) | GFP_ATOMIC;
+ ha->cp[i].sglist = kmalloc(sz, gfp_mask);
+ if (!ha->cp[i].sglist) {
+ printk
+ ("%s: kmalloc SGlist failed, mbox %d, detaching.\n",
+ ha->board_name, i);
+ goto release;
+ }
+ }
+
+ if (!(ha->sp_cpu_addr = pci_alloc_consistent(ha->pdev,
+ sizeof(struct mssp),
+ &ha->sp_dma_addr))) {
+ printk("%s: pci_alloc_consistent failed, detaching.\n", ha->board_name);
+ goto release;
+ }
+
+ if (max_queue_depth > MAX_TAGGED_CMD_PER_LUN)
+ max_queue_depth = MAX_TAGGED_CMD_PER_LUN;
+
+ if (max_queue_depth < MAX_CMD_PER_LUN)
+ max_queue_depth = MAX_CMD_PER_LUN;
+
+ if (tag_mode != TAG_DISABLED && tag_mode != TAG_SIMPLE)
+ tag_mode = TAG_ORDERED;
+
+ if (j == 0) {
+ printk
+ ("EATA/DMA 2.0x: Copyright (C) 1994-2003 Dario Ballabio.\n");
+ printk
+ ("%s config options -> tm:%d, lc:%c, mq:%d, rs:%c, et:%c, "
+ "ip:%c, ep:%c, pp:%c.\n", driver_name, tag_mode,
+ YESNO(linked_comm), max_queue_depth, YESNO(rev_scan),
+ YESNO(ext_tran), YESNO(isa_probe), YESNO(eisa_probe),
+ YESNO(pci_probe));
+ }
+
+ printk("%s: 2.0%c, %s 0x%03lx, IRQ %u, %s, SG %d, MB %d.\n",
+ ha->board_name, ha->protocol_rev, bus_type,
+ (unsigned long)shost->io_port, shost->irq, dma_name,
+ shost->sg_tablesize, shost->can_queue);
+
+ if (shost->max_id > 8 || shost->max_lun > 8)
+ printk
+ ("%s: wide SCSI support enabled, max_id %u, max_lun %u.\n",
+ ha->board_name, shost->max_id, shost->max_lun);
+
+ for (i = 0; i <= shost->max_channel; i++)
+ printk("%s: SCSI channel %u enabled, host target ID %d.\n",
+ ha->board_name, i, info.host_addr[3 - i]);